Suppose that at the end of every month you need to send a progress report to your boss. You might set up a script to address an email message to your boss, provide an appropriate subject line, and send the file containing the progress report. You'd likely have this script automatically address a message to your boss and put in the subject line, but you'd want to use command-line input to tell the script which file you want to send. By using command-line input, you can give your scripts a bit more flexibility and still have much of a process automated for you. You run the script and specify the input at the shell prompt, as shown in Figure 10.7. Figure 10.7. Using command-line input, you can add flexibility to a script and still have the script do the grunt work for you.To Accept Command-Line Arguments in a Script:
Code Listing 10.6. By providing command-line input, you can control what the script does.
Tips
|