tailieunhanh - Mastering unix shell scripting phần 10

Bước tiếp theo là câu chữ biến BASE_TO cơ sở số mục tiêu. Đây cũng là thực hiện bằng cách sử dụng END_BASE trước đây được định nghĩa biến, như ở chữ-i $ END_BASE KẾT giờ chúng ta hãy giả định rằng các cơ sở số mục tiêu, $ END_BASE là 16. | 608 Chapter 23 RESULT 2 1101101011 The next step is to typeset the BASE_TO variable to the target number base. This is also accomplished using the previously defined variable END_BASE as shown here. typeset -i END_BASE RESULT Now let s assume that the target number base END_BASE is 16. The following command statement is equivalent to the preceding variable statement. typeset -i16 RESULT The only thing left to do is print the result to the screen. You can use echo print or printf to display the result. I still like to use echo so this is the final line of the shell script. echo RESULT Other Options to Consider As with all of the scripts in this book we can always make some changes to any shell script to improve it or to customize the script to fit a particular need. Software Key Shell Script To make a software key more complicated you can hide the hexadecimal representation of the IP address within some pseudo-random numbers which we studied in Chapters 10 and 21. As an example add five computer-generated pseudo-random numbers as both a prefix and a suffix to the hexadecimal IP address representation. Then to verify the license key in your software program you can extract the hex IP address from the string. There are several techniques to do this verification and I am going to leave the details up to you as a little project. This is the only modification that I can think of for this chapter. Summary We went through a lot of variations in this chapter but we did hit the scripts from different angles. Number base conversion can be used for many purposes and we wrote one script that takes advantage of the translation. Software keys are usually more complicated than this script example but I think you get the basic idea. In the next chapter we are going to look at creating a menu that is suitable for your operations staff because you rarely want the Operators to have access to the command line. See you in the next chapter BHAPHEn 24 Menu Program Suitable for Operations

TỪ KHÓA LIÊN QUAN