Line in bash script to wait for x feedbacks and then continue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Line in bash script to wait for x feedbacks and then continue
# 1  
Old 04-15-2010
MySQL Line in bash script to wait for x feedbacks and then continue

I have a script that runs a console/terminal command on the server and what is want is for each of the multiple success reports fed back from the clients (echo-ed out onto the conosle) to be counted and after x number of reports reboot the server.

The Details:
The command (program) is clonezilla and in one line of the script it kicks off a job to roll out an image to a bunch of PCs. As the PCs are finished being imaged they report back to the clonezilla server (Ubuntu) by echo-ing a line on the script console/terminal to report the success and the time it took to image each partition on the drive.
I had a counter in the script that just counted down 20 minutes and then stoped the DHCP server. It also prevented the script terminal from closing and the reports from being visible. It was nice to see the reports but more important to stop the DHCP server. I really want the script to wait for the clients to report back and then reboot the server.
The DHCP server that temporarily runs on the Ubuntu clonezilla server (for PXE boot) interferes with the production DHCP server, which has reserved IP addresses based on the client MAC addresses (it is also the gateway for the clients). So I want the image server to reboot (dual boot, so boots back to XP (default)) so that the DHCP servers do not conflict and the clone server is 'hidden'.
If anyone knows how I can block the server from seeing the default gateway/firewall on layer two then that would be a bonus. Right now I have to physically unplug the network cable to prevent the multicast image job from running super slow and stay at the 3 to 4GB per minute as it does. IP tables didn't work.

Here is the whole script including the last line, which I think may work and do what I want but I am hoping to get a confirmation and the best way to do this. I am looking to learn more bash scripting too.
I thought about about a while loop.



Code:
#!/bin/bash
echo
echo "How many clients would you like to image?"
echo
read X
echo
echo "You have chosen to image $X clients. Before you restart those $X clients"
echo "please enter the Administrator password..."
echo
# read -p "Press ENTER key to continue"
# password is requested when dhcp3 server starts
sudo /etc/init.d/dhcp3-server start
# next line is to kick of the mulitcast clone job in one line. Clonezilla rocks.
sudo /opt/drbl/sbin/drbl-ocs -b -g auto -e1 auto -e2 -r -x -j2 -p reboot --clients-to-wait $X --max-time-to-wait 300 -l en_US.UTF-8 startdisk multicast_restore XP-UBUNTU-IMAGE sda
clear
echo "Please reboot the client PCs now."
echo "The job will start 5 minutes after the first client PXE boots"
echo "or when all $X clients are PXE booted.
echo"
read -p "Waiting for the $X images to finish then going to reboot."
[ "$REPLY" == "succeeded" ] || sudo shutdown -r

Here is an example of the line echo-ed back when I client is finished cloning.

Client 192.168.0.11 (00:1e:c9:30:c3:f1) finished cloning. Stats: Multicast restored XP-Ubuntu-IMAGE, /dev/sda1, success, 40164 MB, 81.109 mins, 492.0 MB/min; /dev/sda2, success, 36964 MB, 22.640 mins, 1632.0 MB/min;

Last edited by dp123; 04-15-2010 at 03:41 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add new line after 'continue' in if statment

Hello, im creating a csv file for email reporting on issues. my problem is that after 'continue' command in if statment in a loop the new paramter writing into the log doesnt take new line. timeout 4s zabbix_get -I $ZBX -p $PORT -s $IP -k "system.run" if ; then ... (3 Replies)
Discussion started by: batchenr
3 Replies

2. Shell Programming and Scripting

Wait and continue if directory stays same size

hi all, i want to make a bash script so it can monitor directory sizes ie if it stays the same size (for a certain time) i want it to run the script but if there still copying and the directory increases in size do not run the script i have heard "inotifywait" can do this, but theres... (7 Replies)
Discussion started by: robertkwild
7 Replies

3. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

4. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

5. Shell Programming and Scripting

Bash script parallel tasks and command to wait untill complete?

Hello, im having bash script with while *** command1 && command2 && command3 && done i want to ask how i can prevent overloading server, by waiting untill all commands complete? any low resources intensive command like "wait" - i dont know if exist? (2 Replies)
Discussion started by: postcd
2 Replies

6. Shell Programming and Scripting

BASH - read does not wait for user input in some circumstances

Hello. I am running 2 scripts : script_1 and script_2 These scripts are run as root Script 2 contains : #!/bin/bash # # ~/bin/script_2 # E_BAD_PARAM=115 # date2stamp () { date --date "$1" +%Y-%m-%d___%H:%M:%S } # USER_NAME=$1 NB_PARAM=$# PARAM0=$0 (2 Replies)
Discussion started by: jcdole
2 Replies

7. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

8. Shell Programming and Scripting

Continue an instruction on more than one line in a script shell ?

Hello, I have a very long instruction to write, but, for lisibility reasons, I would like to cut it on more than one line and comment each lines. is it possible ? thanks :b: (1 Reply)
Discussion started by: shadok
1 Replies

9. Shell Programming and Scripting

continue line in perl script

HI , I am new to the perl , I am using a if condition and in that if condition i am checking 7 variables value. so it continue to second line .And if i user "\" for the continue line it showing error. Example : if(a >9 || b>8 || c> 10 \ d > 11) { print(); } The above statement is... (3 Replies)
Discussion started by: julirani
3 Replies

10. Shell Programming and Scripting

Continue output redirection on the same line?

I have for i in 1 2 3 4 do echo $i >> test.txt done test.txt contains ... 1 2 3 4 But I want it to contain ... 1234 Any suggestions? (3 Replies)
Discussion started by: Bandit390
3 Replies
Login or Register to Ask a Question