Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion ssh in a loop
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dan Mercer  
View profile  
 More options Oct 24 2003, 11:48 am
Newsgroups: comp.unix.shell
From: "Dan Mercer" <dmer...@mn.rr.com>
Date: Fri, 24 Oct 2003 15:46:05 GMT
Local: Fri, Oct 24 2003 11:46 am
Subject: Re: ssh in a loop

"Adam Selene" <NOS...@NOSPAM.COM> wrote in message news:4IOdnQy7DN-1lASiRVn-sg@speakeasy.net...

: Hello,
:
: I am trying to write a script that will collect output from a list of
: machines on my network.  To accomplish this I have setup ssh keys and have
: written a simple loop.  The only problem is my script does not go through
: the entire iteration of all the machines, just the first one it grabs during
: read.  Here is my code:
:
: #!/usr/local/bin/bash
:
:    cat machines.list |while read line ;
Useless Use of cat followed by a useless semi-colon
:    do
:        ssh -t myuserid@$line $1 >> /home/myuserid/output.txt
Stdin for the process is the pipe from cat.  SSH inherits stdin and
empties it.  use the -n option

while read line
   do
   ssh -n -t myuserid@$line $1
   done <machines.list >>~/output.txt
clear
less >>~/output.txt

Or you could pipe the results directly to less:
while read line
   do
   ssh -n -t myuserid@$line $1
   done <machines.list |less

Dan Mercer

:    done
:    clear
:    less /home/myuserid/output.txt
:
: The contents of machines.list is:
:
: proxy-01.mydomain.com
: proxy-02.mydomain.com
: proxy-03.mydomain.com
: proxy-04.mydomain.com
: proxy-05.mydomain.com
:
: When I run the script it grabs the output from the first machine in the list
: but goes no further.  What am I doing wrong here?
:
:
: Thanks in advance,
:
: Adam
:
:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google