Re: OT: bash script - unexpected exit
- From: Kevin Martin <kevintm@xxxxxxxxxxxxx>
- Date: Mon, 16 Jan 2012 10:50:21 -0600
On 01/16/2012 10:29 AM, Hiisi wrote:
Hi, list.put a 'set -x' in there so you can see what's happening during the execution. It would be interesting to know what $line is getting
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
set to. You may be surprised.
Kevin
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
- Follow-Ups:
- Re: OT: bash script - unexpected exit
- From: Hiisi
- Re: OT: bash script - unexpected exit
- References:
- OT: bash script - unexpected exit
- From: Hiisi
- OT: bash script - unexpected exit
- Prev by Date: OT: bash script - unexpected exit
- Next by Date: Re: Stuck and Frustrated : Try to get from Live CD to Desktop system Fedora 16.
- Previous by thread: OT: bash script - unexpected exit
- Next by thread: Re: OT: bash script - unexpected exit
- Index(es):
Relevant Pages
|