LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Unable to connect morethan a server via remotely and get the result (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-connect-morethan-a-server-via-remotely-and-get-the-result-4175443283/)

Srinivas Gadi 12-28-2012 01:58 PM

Unable to connect morethan a server via remotely and get the result
 
Hello
Have a question.

Please refer my code

#!/bin/sh
i=1
while read line
do
echo "$i:$line";ssh $line 'nvidia-smi |grep -i MB | cut -c40-55'
let i++
done < ~/hostnames

There are ~100 server , i want remotely loginto all servers one by one and get the nvidia details, when i execute the above scrips it just fetch the details from one server post it quite, it does not heading to second server listed in hostnames file.

Please correct where i was wrong and wt should i do to fulfill my request

theNbomr 12-28-2012 05:23 PM

Please post a fragment of the output, and the hostnames file (in [CODE] [/CODE] tags please, to preserve formatting for those who will test the data).
--- rod.

Srinivas Gadi 01-02-2013 04:34 AM

Output should be as follows
1 144MB / 511MB
2 144MB / 511MB
3 144MB / 511MB

here is the hostname file
MM31.hyd
MM16.hyd
MM54.hyd
MM86.hyd

TB0ne 01-02-2013 12:14 PM

Quote:

Originally Posted by Srinivas Gadi (Post 4861129)
Output should be as follows
1 144MB / 511MB
2 144MB / 511MB
3 144MB / 511MB

here is the hostname file
MM31.hyd
MM16.hyd
MM54.hyd
MM86.hyd

...and you didn't post the output you are getting, as was requested. Without knowing what it's doing, we can't help.

And again, please use CODE tags.

shivaa 01-02-2013 12:39 PM

Does it quit after displaying output of first server, or stuck after that? Perhaps, it's not able to connet to second server...
Once add set -xv to debug the code, as:
Code:

#!/bin/sh
set -xv
i=1
while read line
do
echo "$i:$line";ssh $line 'nvidia-smi |grep -i MB | cut -c40-55'
let i++
done < ~/hostnames



All times are GMT -5. The time now is 06:18 AM.