1751765 Members
4600 Online
108781 Solutions
New Discussion юеВ

Script Debugging

 
Nikee Reddy
Regular Advisor

Script Debugging

Hello,

I have included the following lines in my script to debug it. Unfortunately the debugging is not working.

#!/bin/sh
set -x

Thanks,
Nikee
5 REPLIES 5
Mel Burslan
Honored Contributor

Re: Script Debugging

could you possibly include the actual script or at least the 10-15 lines following the set -x command, so that more educated gusees can be done ?
________________________________
UNIX because I majored in cryptology...
G. Vrijhoeven
Honored Contributor

Re: Script Debugging

Hi,

You could add a v:

#!/usr/bin/ksh
set -vx
.........
set +vx

Regards,

Gideon
A. Clay Stephenson
Acclaimed Contributor

Re: Script Debugging

Well, that should work. About all I can suggest is that you look for and install the latest cumulative POSIX shell patch for your OS release.
If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: Script Debugging

If you added set -x, then you will see your script traced. NOTE: all trace output goes to stderr, not stdout. So if you saved stdout in a file, the trace output went some other place. Are you running this script from cron or at? If so, the debug trace output was emailed to the user running the script. To get evrything sent to stdout, you can trace your script without set -x like this:

sh -x your_script > your_log 2>&1


Bill Hassell, sysadmin
Bill Hassell
Honored Contributor

Re: Script Debugging

One additional note: functions will not be traced without explicitly adding set -x in each function. Note also that set -v also add the original lines of the script mingled in with the trace.


Bill Hassell, sysadmin