if echo "ls filename" | sftp hostname 2>&1 | grep "No such file"
then
echo "filename does not exist on hostname"
exit 1
else
echo "filename does exist on hostname"
fi
Something like this if you're running Korn shell on both sides...
Code:
if [[ "YES" == $(ssh user@hostname "[[ -f filename ]] && print YES") ]]
then
print "filename exists on hostname"
else
print "filename DOES NOT exist on hostname"
exit 1
fi
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.