Debugging Scripts


As you're developing scripts, you'll no doubt encounter a few problems in getting them to run properly. As Figure 10.9 shows, you can help debug your scripts by printing the script onscreen as it runs. That way, you can follow the script as it runs and see where the problems might be.

Figure 10.9. Printing the script onscreen as it runs is a great way to debug it.


To Print the Script Onscreen as it Runs:

  • sh -x retentive

    At the shell prompt, type sh -x followed by the script name (and any additional information you need to provide). The -x tells the shell to both execute the script (as usual) and print out the individual command lines, as shown in Figure 10.9.

Tip

  • Use the name of any shell, followed by -x, followed by the script name for this kind of debugging output. For example, try bash -x retentive.





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net