exit codes from rexec?

Thread Tools Search this Thread
# 1  
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  
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  

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.

It still returns 0!!! Smilie
# 4  
Single quotes otherwise the shell will expand $?

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

# 5  
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
Exit codes
I am trying to run this SH on Linux and getting error at IF condition. I want to read the EXIT code and send the failure or success message. Please help me on this. This worked when i was running on Solaris. #!/bin/bash $ORACLE_HOME/bin/sqlplus abc/xyz@qwe @/home/test.sql if ;...... Linux
Exit Codes
Good Morning All.. I was wondering about getting exit codes of a command in a shell script. I'm trying to run uvscan (McAfee command line scanner) and I want to have the log file say why, if at all, the process failed/exited. Something to the extent of If ; then echo "This is why it...... Shell Programming and Scripting
Shell Programming and Scripting
Exit codes in SFTP
HI All, I have created a unix script which takes 2 parameters and using sftp tranfers files to remote location following is the script #!/bin/ksh # # # Parameter 1 is the complete path of the destination server # Parameter 2 is the complete path of the file which is to be FTP...... Shell Programming and Scripting
Shell Programming and Scripting
Where can I find a list of exit codes? (Exit code 64)
Iím receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. Iím assuming the exit code is from the Unix operating system not PERL.... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
exit codes
donna carter
Where can a locate a list of Unix exit codes? thank you, Donna... Programming