exit codes from rexec?

Tags
beginners

 

 
Thread Tools Search this Thread
# 1  
Old 08-12-2005
exit codes from rexec?

how do i/is there a way to return the exit code from the remote host?
echo $? from the local host only gives 0, if the rexec command itself executes successfully. But what if in the case of the remote command failiing? echo $? on the localhost still gives 0, but I'm interested in the exit code from the failing command on the REMOTE host...
# 2  
Old 08-12-2005
On the remote host echo the exit code after the command has completed and use that on the localhost by using tail -1 on the output of the rexec command.
# 3  
Old 08-16-2005
Data

hi reborg and all,
i tried that and it still returns 0. i even rexec'ed a nonsense command (something like "lsdflkjfd" - which I'm sure doesn't do anything...) and the echo $?, as in:

rexec server1 "lsdflkjfd; echo $?"
i log in with username and password, and it echoes back:

ksh: lsdflkjfd: not found.
0

It still returns 0!!! Smilie
# 4  
Old 08-16-2005
Single quotes otherwise the shell will expand $?

Here is what I get:
Code:
# rexec aserver 'dummy; echo $?'
ksh: dummy:  not found
127

# 5  
Old 05-04-2009
Why it worked for reborg but not for diego

The difference is that diego surrounded the remote call with double quotes, and reborg used single quotes.

In diego's case, his shell interpreted the string before sending it as an arg to rexec, so rexec passed the command ""lsdflkjfd; echo 0"

As reborg pointed out, its vital you use single quotes
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Return or exit codes apart from 0 have a meaning? Tribe Programming 3 08-23-2015 06:12 PM
Retaining exit codes using nc command SkySmart Shell Programming and Scripting 3 07-22-2014 01:16 PM
FTP exit and error codes dhruuv369 Shell Programming and Scripting 7 06-25-2014 10:16 AM
Bash Shell Script Exit Codes metallica1973 Shell Programming and Scripting 6 01-25-2012 08:24 PM
Exit codes rlmadhav Linux 4 05-05-2010 02:28 PM
SCP Exit Codes rogersed Shell Programming and Scripting 1 10-20-2008 02:59 AM
Exit Codes cmschube Shell Programming and Scripting 1 04-04-2008 12:34 PM
difference b/t the exit codes $* and $@ praveen_b744 Shell Programming and Scripting 1 09-19-2007 10:53 AM
Exit codes in SFTP vikramsnest Shell Programming and Scripting 1 08-16-2007 03:08 AM
Solaris Patch exit codes Tornado Tips and Tutorials 1 06-04-2007 10:39 PM
Explanation for the exit codes 2 sesedada UNIX for Advanced & Expert Users 1 06-25-2006 03:31 AM
Exit codes in Korn shell miltony UNIX for Advanced & Expert Users 2 03-15-2006 08:33 AM
Catching all Exit Codes Sivaswami J Shell Programming and Scripting 3 02-16-2006 07:13 PM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 06:08 PM
exit codes donna carter Programming 3 05-31-2001 10:35 PM