Tools to debug

Posted on 2006-04-30
Medium Priority
Last Modified: 2013-12-27
Could someone tell me what tools I can use to debug shell scripts?  
Question by:Higante
LVL 10

Assisted Solution

Nukfror earned 1000 total points
ID: 16572786
Depends what shell.   The Bource shell derivatives (sh, ksh, bash) have the -v and -x switches.

You can see more on ksh debugging here: http://www.unix.org.ua/orelly/unix/ksh/ch09_01.htm

Perl has the Perl debugger:  perl -d .....  << this rocks

I don't use csh so I can't say how to debug it ... csh needs a bullet in the head.
LVL 38

Accepted Solution

yuzh earned 1000 total points
ID: 16574596
Please tell us the with shell you are using for scripting.

For sh/ksh/bash script you can add the following line as the 2nd line of your script:

set -x  

make your script looks like:

set -x

#your main script goes to here

For csh, it is possible to debug a script by adding the -x flag to the shell executable
   % csh -x scriptname arguments

I sugest you to use ksh or sh for scripting, please read this " Csh Programming Considered Harmful":


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question