Operating System - Linux
1752821 Members
4396 Online
108789 Solutions
New Discussion юеВ

Return codes from remote commands

 
Robert S. White
Advisor

Return codes from remote commands

This should be a simple problem.
I need to test for the existance of a file on a remote host. rsh test -f does not work because not matter what the result of the test command, rsh completes sucussfully ( ie returns 0 ).
I'm checking $?.
Any ideas would be helpful.
Computers are just external storage for my brain.
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Return codes from remote commands

Hi Robert:

Write the result of the file test into a *file* that you fetch to retrieve to determine the success or failure.

Regards!

...JRF...
Kofi ARTHIABAH
Honored Contributor

Re: Return codes from remote commands

How about this:

filespec=/path/to/file
RESULT=`remsh remotehost "ls $filespec" 2>&1`
if [ "$RESULT" = "$filespec" ]
then
#found the file ... do something
else
# nothing found ... do something else
fi

HTH. Good luck
nothing wrong with me that a few lines of code cannot fix!
Robert S. White
Advisor

Re: Return codes from remote commands

Wow that was quick.
Kofi ARTHIABAH your solution is a gem.
I was thinking that I would need to do something like what JRF listed, but your solution is the simple one I needed!


Thank you!
Computers are just external storage for my brain.