Here is an example of a check if a file exists on the remote server and takes action locally, inside a shell script.

Code:
if [ $(ssh devopsrun2 [[ -f /etc/passwd ]];echo $?) -eq 0 ]; then
    echo "Remote file exists"
fi

The remote testing section:
Code:
ssh devopsrun2 [[ -f /etc/passwd ]]
This command will ssh to the host devopsrun2 and test if file exists
Code:
echo $?
This will echo the return status of ssh command file check, will return 0 if it was a success, 1 if the file was not existing.

There is another way to check in Command-line: https://www.devopsrun.com/t-how-to-check...mmand-line