Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ssh in a loop

219 views
Skip to first unread message

Adam Selene

unread,
Oct 24, 2003, 7:12:13 AM10/24/03
to
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 ;
do
ssh -t myuserid@$line $1 >> /home/myuserid/output.txt
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


Andreas Kahari

unread,
Oct 24, 2003, 8:51:17 AM10/24/03
to
In article <4IOdnQy7DN-...@speakeasy.net>, Adam Selene wrote:
[cut]

> #!/usr/local/bin/bash
>
> cat machines.list |while read line ;
> do
> ssh -t myuserid@$line $1 >> /home/myuserid/output.txt
> done
> clear
> less /home/myuserid/output.txt
[cut]

> 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?


Are you usually able to connect with ssh to the machines in
question without having to provide a password?


--
Andreas Kähäri

Dan Mercer

unread,
Oct 24, 2003, 11:46:05 AM10/24/03
to

"Adam Selene" <NOS...@NOSPAM.COM> wrote in message news:4IOdnQy7DN-...@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

:
:


Kevin Rodgers

unread,
Oct 24, 2003, 11:50:28 AM10/24/03
to
Adam Selene wrote:

Presumably the ssh command is reading standard input, which is the list of
machine names, and sending it to the first remote machine. Does ssh provide
a -n option, like rsh?

--
Kevin Rodgers

Bill Marcum

unread,
Oct 24, 2003, 10:13:38 AM10/24/03
to
The while loop's standard input comes from "cat machines.list". Unless
you redirect input for ssh, it will also read from the pipe.


--
You can go anywhere you want if you look serious and carry a clipboard.

Adam Selene

unread,
Oct 24, 2003, 3:00:14 PM10/24/03
to
"Dan Mercer" <dme...@mn.rr.com> wrote in message
news:1Pbmb.70116$832....@twister.rdc-kc.rr.com...

Thank you! The -n is just what I needed.


Thanks again,

Adam


JasonJames HisWife

unread,
Nov 19, 2020, 6:56:22 AM11/19/20
to
Just popped up on my phone as the mechanic 🧰 the hospital 🏥❤️ jjnkjdrea...@jnk.org.in ❤️ KJ ❤️ JJ ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Keep Update the hospital for The police department 🏬🏬 the mechanic and called me enough to get in the shower now then I'll be home to get in touch to let you have a lot ❤️ jjnkjdrea...@jnk.org.in ❤️8

JasonJames HisWife

unread,
Nov 19, 2020, 6:59:32 AM11/19/20
to
On Friday, October 24, 2003 at 12:00:14 PM UTC-7, Adam Selene wrote:
> > Dan Mercer's the other one of the street to do it again soon and I will be in your area tomorrow morning 🌅🌄 the office and they told her that this stuff is in manual testing profile picture is of experience with the link 🔗 firebase and I hope to hear from you soon thank 📱❤️ jjnkjdrea...@jnk.org.in ❤️ KJ ❤️ KJ ❤️ JJ ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James and His Lawyer's office today so much for all the information ℹ️ ℹ️ the hospital 🏥❤️ Kylie Jenner Jason James ❤️ Kylie Jenner Jason James ❤️ Kylie and I can 🥫🥫 you can get it Again 😁 and again I apologise and again thank you so very happy with the link 🔗 firebase I can 🥫 and called the mechanic 🧰 the hospital 🏥❤️ JJ ❤️ Kylie Jenner Jason James ❤️ Keep Updated resume enclosed the details of experience in manual testing resume enclosed my CV attached herewith is called me enough names of the street to get anything done ✅

Esau Laguna

unread,
Oct 9, 2022, 2:01:45 PM10/9/22
to
Josue esau laguna gamez

Esau Laguna

unread,
Oct 9, 2022, 2:02:49 PM10/9/22
to
El jueves, 19 de noviembre de 2020 a la(s) 05:59:32 UTC-6, JasonJames HisWife escribió:
https://groups.google.com/g/comp.unix.shell/c/POLBma_q7FI/m/ez_CzcDFBAAJ

David W. Hodgins

unread,
Oct 9, 2022, 5:23:07 PM10/9/22
to
On Sun, 09 Oct 2022 14:01:42 -0400, Esau Laguna <esaula...@gmail.com> wrote:

> El jueves, 19 de noviembre de 2020 a la(s) 05:59:32 UTC-6, JasonJames HisWife escribió:
>> On Friday, October 24, 2003 at 12:00:14 PM UTC-7, Adam Selene wrote:
>> > "Dan Mercer" <dme...@mn.rr.com> wrote in message
>> > news:1Pbmb.70116$832....@twister.rdc-kc.rr.com...

Please learn to look at the dates. You're following up to a 2 year old message
that was a follow up to a 7 year old message.

I know google groups wants to make it look like this is a google group, but it's
usenet news group that google copies, poorly.

Regards, Dave Hodgins

Janis Papanagnou

unread,
Oct 9, 2022, 5:39:28 PM10/9/22
to
On 09.10.2022 23:14, David W. Hodgins wrote:
> On Sun, 09 Oct 2022 14:01:42 -0400, Esau Laguna <esaula...@gmail.com>
> wrote:
>
>> El jueves, 19 de noviembre de 2020 a la(s) 05:59:32 UTC-6, JasonJames
>> HisWife escribió:
>>> On Friday, October 24, 2003 at 12:00:14 PM UTC-7, Adam Selene wrote:
>>> > "Dan Mercer" <dme...@mn.rr.com> wrote in message
>>> > news:1Pbmb.70116$832....@twister.rdc-kc.rr.com...
>
> Please learn to look at the dates. You're following up to a 2 year old
> message
> that was a follow up to a 7 year old message.

ITYM; "a follow up to a 17 year old message."

Janis

David W. Hodgins

unread,
Oct 9, 2022, 6:48:04 PM10/9/22
to
Lol. Yep.

Regards, Dave Hodgins
0 new messages