I use

sh -xv my_script.sh

to debug the /bin/sh script. How do I debug /bin/bash scripts?

I am getting the following error and I need to know the line that needs to edit.

# ./batch_master.sh

'@'10.10.10.10.' (using password: NO)user 'companycuser
link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

Doesn't this work?

bash -x ./batchmaster_sh
link|improve this answer
It does work. But shows a lot of junk. I want to know only the mysql command that does not work. I do not see that anywhere in the output. The output is much lengthy than expected. – shantanuo Sep 2 '11 at 10:01
Well... what happens if you grep 10.10.10.10 ./batch_master.sh or grep mysql ./batch_master.sh :) – Janne Pikkarainen Sep 2 '11 at 10:35
feedback

Edit the script, add a -x option to the shell command line like:

#!/bin/sh -x

or

#!/bin/bash -x

It will print all executed commands and you can see what is done after what.

link|improve this answer
Thanks for your inputs. The problem got solved after running dos2unix command on the properties file. – shantanuo Sep 2 '11 at 10:18
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.