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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exit status

Status
Not open for further replies.

vlz

IS-IT--Management
Aug 11, 2002
56
IL
Hi,
I need to get exit status of the remote command.
For example:
a=/tmp/myfile
remsh host "ls $a;echo $?"

The problem is that I have to use variable and not it value:
i.e. I can't use this:
remsh host 'ls /tmp/myfile;echo $?'

Thanks in advance,
Vadim
 
Have you tried [tt]remsh host "ls $a;echo \$?"[/tt]? //Daniel
 
Thanks Daniel,
It works for ksh.
I tried the same solution for tcsh, but I get the
status from the local machine.
i.e.
set a=/tmp/myfile # this file doesn't exist on remote host
remsh host "ls $a;echo \$status"

<output>:
/tmp/myfile not found
0

Is there also solution for tcsh?
 
remsh host &quot;ls $a > /dev/null 2>&1;echo \$status&quot; vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi Vlad,
I work in tcsh on the both hosts (local and remote)
So I run
remsh host &quot;ls $a >& /dev/null;echo \$status&quot;

<output>
0

still I get local exit status
 
........ and &quot;$a&quot; does NOT exist on the remote host?

when you do &quot;remsh host&quot;, what shell do you get? [do &quot;echo $0&quot; once on the 'other' side] vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
variable $a is defined only on the local host.
when I do remsh host I get tcsh shell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top