#!/bin/sh
ssh [username]@[ip] "bash -s" <<EOF
if [condition]
then
echo "success"
else
echo "failure"
fi
EOF
After running these commands, I want to save the result (ie success/failure) in a file on local machine. How do I go about it?