OT: bash script - unexpected exit
Hiisi
hiisi at fedoraproject.org
Mon Jan 16 16:29:04 UTC 2012
Hi, list.
Sorry for OT. I like this list and really appreciate your help. Please
excuse me if this post irritates you.
I want to write a bash script that will do some work on a LAN. Here's
the script (at least I execute it on Fedora machine ):
#!/bin/sh
set -e
cat hosts | while read line
do
if (! grep -q repo.corp.macros /etc/apt/sources.list ); then
echo $?
sshpass -p '*****' ssh -o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no -o ConnectTimeout=3 master@$line 'echo
"*****" | sudo -S sed "s/http:\/\//http:\/\/repo.corp.macros:3142\//g"
/etc/apt/sources.list > /home/master/sdjhfklj' ; echo $?
sshpass -p '*****' ssh -o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no -o ConnectTimeout=3 master@$line 'echo
"*****" | sudo -S echo "deb
http://repo.corp.macros:3142/apt-cache/repo /" >>
/home/master/sdjhfklj' ; echo $?
sshpass -p '*****' ssh -o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no -o ConnectTimeout=3 master@$line 'echo
"*****" | sudo -S mv /home/master/sdjhfklj /etc/apt/sources.list';
echo $?
fi
done
The problem is that it never works for more than one host. I.e. in
hosts file there's 36 hosts. The script works as expected on the first
one and then it exits. ERRORLEVEL ($?) is always zero at each point.
What am I doing wrong and how to modify it?
TIA
--
Hiisi.
Registered Linux User #487982. Be counted at: http://counter.li.org/
--
Spandex is a privilege, not a right.
More information about the users
mailing list