LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2009, 07:55 AM   #1
soumyacs
LQ Newbie
 
Registered: Oct 2009
Posts: 21

Rep: Reputation: 0
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
 
Old 10-27-2009, 08:03 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
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
 
Old 10-27-2009, 09:07 AM   #3
soumyacs
LQ Newbie
 
Registered: Oct 2009
Posts: 21

Original Poster
Rep: Reputation: 0
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 ??
 
Old 10-27-2009, 09:25 AM   #4
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
do it like this:
Code:
if ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'; then
   echo "connected"
else
   echo "not connected"
fi
 
Old 10-27-2009, 09:48 AM   #5
soumyacs
LQ Newbie
 
Registered: Oct 2009
Posts: 21

Original Poster
Rep: Reputation: 0
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
 
Old 10-27-2009, 10:03 AM   #6
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Code:
if ssh -f <IPADDRESS1> '/root/Desktop/a.sh &'; then
   variable="connected"
else
   variable="not connected"
fi
echo "variable is $variable"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ftp: connect: No route to host dwarf007 Linux - Networking 15 03-22-2013 02:55 PM
ssh: No route to host thanhvn Linux - Software 6 06-30-2005 07:18 AM
Connect Failed: not route to host frankjp Linux - Networking 4 06-15-2005 11:09 PM
ftp: connect: No route to host agki Linux - Networking 2 03-09-2005 04:25 PM
ftp connect: no route to host dominant Linux - Networking 4 09-07-2004 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration