Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding error code

Status
Not open for further replies.

nitinkgoud

IS-IT--Management
Jun 28, 2006
87
0
0
US
Hi Guys,
Can you tell me how to find error code generated by a command.
Say i run a command and its generating an error how do i find out its error code ( i know its done using redirection operator.......but not sure how)?
 
Like this...
Code:
#!/bin/ksh

somecommand

STATUS=$?

print "Final status code was ${STATUS}"

# or this way

anothercommand && print "Success!" || print "Failed!"
It's the "[tt]$?[/tt]" that holds the return code from any command, immediately after the command ends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top