How can I Debug a shell scripts and Perl scripting??
or How do you debug a shell scripting and perl scripting (
at the compile time error or run
time error) in Unix environment ?

Answers were Sorted based on User's Feedback



How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and per..

Answer / hema

Using sh -x script argument you can debug(-x option).
Bash shell offers debugging options which can be turn on or
off using
set command.
=> set -x : Display commands and their arguments as they are
executed.
=> set -v : Display shell input lines as they are read.

Hope this answers your question.

Is This Answer Correct ?    12 Yes 1 No

How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and per..

Answer / manas

We can debug only by $? which contains the returned value
of last executed command.

If $? contains 0 value then command run successfully other
wise error occured while running command

Is This Answer Correct ?    3 Yes 2 No

How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and per..

Answer / sushil

In addition to Hema's ans :
We can have some $? statement, echo statements embadded in
script.
In pern we can use -w option to print the warning or erros
generated during compilation, can make use os strict to force
to use good programming practice...

Is This Answer Correct ?    0 Yes 1 No

How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and per..

Answer / ram

We can also use below command to debug the script
bash -xv <scriptname.sh>

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Shell Script Interview Questions

What is a shell environment?

0 Answers  


Write a shell script to check whether a number is Armstrong number or not?

1 Answers   Flipkart,


write a shell script to identify the given string is palindrome or not?

17 Answers   CTS, HP, IBM, InfoEst, Wipro,


What is shell prompt?

0 Answers  


What happens on a system call?

0 Answers  






What is the meaning of $1 in shell script?

0 Answers  


Is it possible to substitute "ls" command in the place of "echo" command?

0 Answers  


How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?

0 Answers  


Given a file find the count of lines containing the word "abc".

0 Answers  


Why is it called a shell?

0 Answers  


write a program to display all the files from the current directory which are created in particular month

6 Answers  


Why should we use shell scripts?

0 Answers  


Categories