- Debug Shell Script
- Posted by Frank on November 20th, 2003
Hi all,
I need to debug a shell script. Which tool shouls I use?
I would like to have step by step line processing, and the way to see
the variables, at least.
thanks
frank
- Posted by Dances With Crows on November 20th, 2003
On 19 Nov 2003 17:09:46 -0800, Frank staggered into the Black Sun and said:
The shell itself provides a good one in the form of "set -x" as the
second line in your script.
You'll get a lot of info with set -x , probably more than you want. To
see variables, just do "echo $VARIABLE # DEBUG" at appropriate points,
then remove all lines with # DEBUG in them when you've fixed the
problem.
--
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
http://www.brainbench.com / "He is a rhythmic movement of the
-----------------------------/ penguins, is Tux." --MegaHAL
- Posted by Alan Connor on November 20th, 2003
On 20 Nov 2003 01:19:05 GMT, Dances With Crows <danSPANceswitTRAPhcrows@usa.net> wrote:
There's a version of Bash with a sophisticated debugger. See comp.unix.shell.
AC
- Posted by Michael Heiming on November 20th, 2003
Frank <frankazev@yahoo.com> wrote:
Put 'set -xv' near the top of your script an rerun it.
--
Michael Heiming
Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM
- Posted by Master Web Surfer on November 20th, 2003
[This followup was posted to comp.os.linux.misc]
In article <34bffecf.0311191709.1ac12c38@posting.google.com>,
frankazev@yahoo.com says...
Shell scripts have the capability to trace themselves.
If the 1st executable statement in your shell script is "set -x" then
the shell script will display the line before it is executed (after the
substitutions have been performed).
See the manpage for your specific shell for more debugging info.