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
Are you usually able to connect with ssh to the machines in
question without having to provide a password?
--
Andreas Kähäri
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
:
:
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
--
You can go anywhere you want if you look serious and carry a clipboard.
Thank you! The -n is just what I needed.
Thanks again,
Adam