I am not clear about the stdout and stderr of ssh because if I execute say :
ssh user@remotemachine_ip "some command"
I get the output instantly on the screen or may be some error
logged in with ssh
remote commands are executed on the remote machine
the output is displayed on the remote machine (stderr or stdout) which I can see. Then it comes back to local machine.
or
the output come back to the local machine's stdout and which can be appended to a file on local machine.
So if I have a for loop in local machine
for i in ip1 ip2
do
ssh user@remotemachine_ip "some command"
done
what is the best way for error redirection and is it dependent on for, while, until loops
what if instead of ssh I am using some expect script
expectscript.exp user@remotemachine_ip "some command"
for ip in ip1 ip2
do
ssh user@$ip "some command" > output.$ip 2>&1
done
will put the output in a separate file for each IP.
for ip in ip1 ip2
do
ssh user@$ip "some command"
done > output 2>&1
will put all the output in a single file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With