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.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.211.87