Atmesh Mishra Atmesh Mishra - 1 year ago 108
Bash Question

ssh to server, run commands and save output of commands on local machine using shell

ssh [username]@[ip] "bash -s" <<EOF
if [condition]
echo "success"
echo "failure"

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?

Answer Source

Good to try is the IO redirection:

ssh [username]@[ip] "bash -s" > file.txt <<EOF
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download