This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes sh file write and debug Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "sh file write and debug" Watch "sh file write and debug" New topic
Author

sh file write and debug

sanjey asok
Ranch Hand

Joined: Jul 11, 2009
Posts: 39
I am new to Unix OS, using Putty to connect Unix server and trying to write sh file and run the sh file.when i run the file,i got many error on it,so wants to debug the sh file, I have absolutely no idea to debug the sh file, so can you suggest how i can do the debugging?,if i get the detailed idea, i would be better.

If there any tool/IDE that i can install on window machine and do the debugging
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32633
    
215

When you say "error" do you mean syntax error or it doesn't do what you want it to?

The easiest way to debug the former is to comment out code until you have a script that doesn't blow up and slowly start adding code back in. The easiest way to debug the later is to add echo statements. I've never used a tool because the UNIX systems I've had access to blocked a UI and command line debugging wouldn't have been easier than what I was doing.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2956
    
  12

sh -x myscript.sh

That at least shows you the commands as they execute. Also, put in lots of echo statements. If you're doing anything really complicated, I recommend looking into Python as an alternative to Bourne Shell scripts. Or Perl ... Perl still exists, right?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sh file write and debug
 
It's not a secret anymore!