RSH command

Hello,

I am trying to determine 2 things on a remote host.

  1. Is file a directory or file
  2. Does the file or directory exist
    Not too familiar with "find" command although I believe that may be a possible way. I have tried:
remsh "$HOST" test -e /home/test.script && echo "yes" 

This returns "yes" whether the test is true or not.

Thanks for the help

From the man page of remsh:

So if you are trying to find the exit status of the remote command, well, you cant. Also your remsh is setting up a connection with remshd successfully, so it returns success and your "&& echo" command goes through.

Thanks Blowtorch. Do you have any suggestions of how I could accomplish this another way?

Thanks.

What exactly are you trying to do? Do you want to check the exit status of the remote command? I think that you could do it this way:

remsh "$HOST" test -e /home/test.script \&\& echo "yes"

The yes will be printed only if the test result is successful, but it will be printed on the local host, so you can store this in a variable and check the variable for the result. Like this:

result=$(remsh "$HOST" test -e /home/test.script \&\& echo "yes")
if [ "$result" = "yes" ]; then
--remote command succeeded. do something--
else
--remote command failed. do something else--
fi