I am checking whether a file exists on a remote server but instead of hardcoding the filename I want to pass in a variable. Is this not possible this way? Should I take an alternative route?
Works:
if ssh "$SSH_USER"@"$SSH_IP_ADDRESS" "echo $OUTPUT1 && cd $SSH_LOC && pwd && echo $SSH_LOC && [ -f live_29-06-2018.txt ];"
then
echo "This file exists."
else
echo "This file doesn't exist."
fi
Displays "This file exists."
Doesn't work:
if ssh "$SSH_USER"@"$SSH_IP_ADDRESS" "echo $OUTPUT1 && cd $SSH_LOC && pwd && echo $SSH_LOC && [ -f $OUTPUT1 ];"
then
echo "This file exists."
else
echo "This file doesn't exist."
fi
Displays "This file doesn't exist."
Aucun commentaire:
Enregistrer un commentaire