If rsh behavies like ssh, then:
ssh user@host "[ -d $DIR ]" && echo "dir exists"
DIRS="Documents Document Downloads Download"
for dir in $DIRS;
do ssh elite "[ -d $dir ]" && echo "$dir exists" || echo "$dir doesn't exist"
Document doesn't exist
Downloads doesn't exist
Your original thread tested different hosts for a directory. Not as easy for me to demonstrate with a real example.
You shouldn't be using rsh if your lan has a network connection. Ssh is a more secure replacement.
You can use:
to be able use public key authentication, and not have to enter the passphrase each time.
Be careful you understand when and where a variable is referenced.
This example will send the command verbatim to the server.
ssh user@host 'ls $HOME/Documents/'
This example will evaluate the variable $dir before executing the ssh command:
ssh user@host "ls $dir/*.pdf"
In my original example, the test "[ -d $dir ]" is made on the server after $dir is referenced on the client. The rest of the line runs on the client ( && echo "$dir exists" || echo "$dir doesn't exist" ).