The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Exit Codes cmschube Shell Programming and Scripting 1 04-04-2008 11:34 AM
difference b/t the exit codes $* and $@ praveen_b744 Shell Programming and Scripting 1 09-19-2007 09:53 AM
Explanation for the exit codes 2 sesedada UNIX for Advanced & Expert Users 1 06-25-2006 02:31 AM
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 High Level Programming 3 05-31-2001 09:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-12-2005
diego_sapphire diego_sapphire is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 2
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 (permalink)  
Old 08-12-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
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 (permalink)  
Old 08-16-2005
diego_sapphire diego_sapphire is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 2
Unhappy

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!!!
  #4 (permalink)  
Old 08-16-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,211
Single quotes otherwise the shell will expand $?

Here is what I get:
Code:
# rexec aserver 'dummy; echo $?'
ksh: dummy:  not found
127
  #5 (permalink)  
Old 05-04-2009
unikoski unikoski is offline
Registered User
  
 

Join Date: May 2009
Posts: 1
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0