Re: OT: bash script - unexpected exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 01/16/2012 10:29 AM, Hiisi wrote:
> 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
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
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


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux