Stop a program without breaking the script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stop a program without breaking the script?
# 1  
Old 01-08-2010
Stop a program without breaking the script?

Hello there!

I am creating a script, that among other functions will run iperf (network stress tool) either on server or client mode.

The thing is that it will run forever if the user does not stop it or break it. CTRL-C will break it. I need a method, however, that will break iperf and then return to the script line right after where it was called:

Code:
echo -n "  Choose mode: [C]lient or [S]erver: "
read MODE
while [ "$MODE" != "C" -a "$MODE" != "S" ]
do
if [ "$MODE" == "S"  ]
then
	iperf -s -i 1
	exit
else
	if [ "$MODE" == "C"  ]
	then
		echo ""
		echo "  Server IP?:"
		read IP
		iperf -c $IP -t 300 -i 1
		exit
	else
	fi
fi
done

Any ideas?
# 2  
Old 01-08-2010
The line right after it is 'exit' anyway. What's the difference?

You can run iperf in the background, and have your script kill it whenever you please.
# 3  
Old 01-08-2010
Quote:
Originally Posted by Corona688
The line right after it is 'exit' anyway. What's the difference?

You can run iperf in the background, and have your script kill it whenever you please.
Nevermind... I thought it would break everything, but it falls right back where I want to... tks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stop child script by stoping parent script

Hi everyone, I have this problem with a script I'm writting. I want to execute a code running in the background several times through a script. I am writting it like that parent_script for a in 1 2 3 4 5 do exec test -n $a done What I want to do is when parent_script is killed,... (0 Replies)
Discussion started by: geovas
0 Replies

2. UNIX for Advanced & Expert Users

rc.d script to stop not workign

I have a simple script that I have put in all the rc.d directories from 1-6 and have named it K20blah and S20blah .I am on red hat linux and I see that when i do reboot the S20blah is ignored but the K20blah is executed during startup . Any suggestions? #! /bin/sh # /etc/init.d/blah # #... (3 Replies)
Discussion started by: gubbu
3 Replies

3. SCO

Restrict user from breaking out of login script

I have a login script similar to where the user's shell in /etc/passwd is set to csh: echo "In .login" setenv SHELL /bin/csh /bin/sh -c trap "" 1 2 3 5 6 7 8 15 /path/to/application logout --------------------- however, even with the trap command the user is still able to... (1 Reply)
Discussion started by: kuliksco
1 Replies

4. Shell Programming and Scripting

Breaking Loop by using another script

Hi friends, I have 2 scripts. 1) Master_Script.sh and 2) Sub_script.sh We run Master_script.sh manually where as sub_script.sh keeps generating output in every 2 minutes (through crontab). The output generated by sub_script.sh can be 0 or 1. As I told you, sub-script.sh keeps generating o/p... (7 Replies)
Discussion started by: anushree.a
7 Replies

5. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

6. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

7. Shell Programming and Scripting

script don't stop

Hello everybody! I am new to this and I am trying to change a script in an open source program that plots some offset vectors and then calls a postscript viewer. I have commented away the call for the postscript viewer but somehow the script doesn't return to the shell prompt. I cant figure out... (3 Replies)
Discussion started by: larne
3 Replies

8. UNIX for Dummies Questions & Answers

Stop a shell script

Hi, I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following: mike=1 if ; then STOP THE SCRIPT fi (3 Replies)
Discussion started by: msb65
3 Replies

9. Shell Programming and Scripting

Script to run non-stop

Hi All, I am on a Solaris OS and i have come up with a csh script named " mycshscript " which will grab data from a datalog file & format the grabbed data & upload formated version to web server. I would want to have this script to run non-stop so that the latest can be captured since data is... (37 Replies)
Discussion started by: Raynon
37 Replies

10. UNIX for Dummies Questions & Answers

Script that doesn't stop

Hi all, I got a script that runs automatically using the cron file. The script starts running at midnight and suppose to delete image files from folders and sub-folders. The script ends when he finishes deleting or after 5 hours. My problem is that the script doesn't stop running even after 5... (3 Replies)
Discussion started by: biot
3 Replies
Login or Register to Ask a Question