Mastering Unix Shell Scripting p10

nhưng một vấn đề phát sinh khi biến chiều dài tối đa, thường là 2048 ký tự, là vượt qua. Nếu bạn có một danh sách dài của các nút mà bạn muốn ping và bạn nhận thấy rằng kịch bản không bao giờ được đến cuối của danh sách ping, | 616 Chapter 24 sleep 1 MSG esac End of Loop until 99 is selected done Erase menu from screen upon exiting with the clear command clear End of Script Listing shell script listing. continued From the Top Let s look at this script from the top. The first step is to define files and variables. In this section we define three variables our BINDIR directory which is the location of all of the shell scripts and programs that we call from the menu. The second variable is the hostname of the password server. I use a single server to hold the master password list and every 15 minutes this master password file is pushed out to all of the other servers in the landscape. This method just makes life much easier when you have a lot of machines to manage. Of course you may use NIS or NIS for this functionality. The last variable is the hostname of the machine running the menu THIS_HOST. Next we initialize two variables one is for the message bar and the other is for the menu options MSG and OPT. After initializing these two variables we set a trap. This trap is just informational. All that we want to do if this shell script receives a trapped signal is to let the user know that this program exited on a trapped signal nothing more. Now comes the fun stuff at the BEGINNING OF MAIN. For the menu we stay in a loop until the user selects 9 9 as a menu option. Only an exit signal or a 9 9 user selection will exit this loop. The easiest way to create this loop is to use a while loop specifying 9 9 as the exit criteria. Each time through the loop we first clear the screen. Then we display the title bar which has the hostname of this machine specified by the THIS_HOST variable. Next we display the menu options. This current menu has 8 options plus the 99 exit selection. We preset the message bar to always assume an incorrect entry. If the entry is valid then we overwrite the MSG variable with blank spaces. After the message bar is displayed we prompt the user for a

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.