tailieunhanh - Mastering Unix Shell Scripting phần 6

. Hoặc nếu bạn thích phương pháp chức năng C-, chúng ta có thể sử dụng ví dụ này, test_function () {function_code}. Sự khác biệt duy nhất giữa hai phương pháp chức năng là một trong những sử dụng chức năng từ để xác định | 332 Chapter 12 unknown to the system because DNS is not configured on this system. The mrranger node is powered down so it is known but not reachable. Notice the difference in the outputs for these two similar but very different situations. Please study the code related to both of these tests in the ping_nodes function. Other Options to Consider As always we can improve on any shell script and this one is no exception. I have listed some options that you may want to consider. PINGLIST Variable Length Limit Problem In this scripting solution we gave the user the capability to comment out specific nodes in the PINGFILE. We assigned the list of nodes which is a list without the comments to a variable. This is fine for a relatively short list of nodes but a problem arises when the maximum variable length which is usually 2048 characters is exceeded. If you have a long list of nodes that you want to ping and you notice that the script never gets to the end of the ping list you have a problem. Or if you see a funny-looking node name which is probably a hostname that has been cut off by the variable limit and associated with a system error message then you have a problem. To resolve this issue define a new file to point to the PINGLIST variable and then we will use the file to store the ping list data instead of a variable. To use PINGLIST as a file add change the following lines ADD THIS LINE PINGLIST tmp CHANGE THIS LINE PINGLIST cat PINGFILE grep -v TO THIS LINE cat PINGFILE grep -v A PINGLIST CHANGE THIS LINE for HOSTPINGING in echo PINGLIST TO THIS LINE for HOSTPINGING in cat PINGLIST Automated Hosts Pinging with Notification 333 Using the file to store the ping list data changes the limit to the maximum file size that the system supports or when the filesystem fills up which should be plenty of space for anyone. This modified shell script is located on this book s companion Web site. The script name is . Ping the etc hosts File

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã 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.