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

rsh issuing remote commands

Status
Not open for further replies.

Greenster

Programmer
Jan 14, 2002
30
GB
Hi, can anyone help me please,

I am using rsh to log-in to a remote server - I can login in fine and issue commmands fine but I am having trouble with my syntax. I want to check if a file exists on a remote server something like this:

rsh -l myname myhost 'if -f path/to/file' return 1 else return 0;

I am very new at writing shell scripts!

Any help would be most appreciated.

Thanks

Greenster
 
The "r" family of commands (rlogin, rexec, rsh) don't pass result codes back very accurately. You'd be well advised to look elsewhere for the functionality.

Bill.
 
I have also tried to do this, and in the end settled for testing the return string from my remote command.
For example I wanted to test the presents of a file, so I listed it, and | the return into "grep" for the error message i.e. "File not found", the $? value is then set to 0 for true, because the grep command succeeded, if the file is found it will give another error messages, grep will fail, and thus return 1, false.
I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top