ssh: connect to host .....No route to host
Hi All,
I am exceuting a script file after connecting a server using ssh . ssh -f <IPADDRESS1> '/root/Desktop/a.sh &' ssh -f <IPADDRESS2> '/root/Desktop/a.sh &' .................... Now Out of 10 ips , 7 ips are connected. For rest of the ips (ie 3) it is showing ssh: connect to host .....No route to host and I am not able to put this connection error in a log file. So , I want a solution that will produce an error/alert message if the ip is not connected as for rest of the ips the script file is being executed properly and getting the desired result..... Thanks in advance |
To put the error to a log file, append this to your ssh command:
Code:
ssh -f <IPADDRESS1> '/root/Desktop/a.sh &' 2>loggile.log |
Thanks... But I need the output also in that log file(of that file of those ips which got connected)
In that log file only error message is coming.. I want to know one thing----------- if [ <ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'> ] is true(got connected and executed) then "connected" else "not connected" is it possible to write this type of code in shell script ?? |
do it like this:
Code:
if ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'; then |
Thanks it is working.
Can you pls tell me how to put this value( either connected or not connected) in to a varible?? I tried this one but is not working.... variable = `if ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'; then echo "connected" else echo "not connected" fi` Can you pls tell me the code?? Thanks in advance |
Code:
if ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'; then |
All times are GMT -5. The time now is 03:02 PM. |