Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.


  Search this Thread
Old 02-05-2007, 04:41 AM   #1
Registered: Sep 2006
Posts: 31
Blog Entries: 1

Rep: Reputation: 15
Writing a Shell Script with a Time Parameter

Hello there,

I want to write a shell script (preferably a Bourne Shell script) that allows me to fork and run certain number of processes for a given period (t) of time. If you haven't got my point yet, let me explain it briefly. The purpose of my experiment is to compare the performance of two different routing protocols (one is mine and the other is somebody else's) in our wireless Linux-based testbed in terms of their power-efficincy. Hence, the idea is to test the performance with the same VoIP (gphone) application under each routing protocol for a given period of time, while keeping all the other environmental settings the same. I have written a special software that periodically monitors as to how many packets have been sent and received in the whole 6-node testbed and how much energy has been depleted. For this purpose, I need to run each routing protocol, gphone and other processes for "t" hours and then stop them. Can somebody please let me know how this can be performed using a script. I have come up with a follwing script:

pid1 = fork("~/gphone -c
pid2 = fork("../../routing_protocol)
pidn = fork("../../monitor_program)
sleep t*60*60*1000 && kill ${pid1} ${pid2} ${pidn}

Do you think that the above script would do the job ?

Thanks in advance for taking your invaluable time to answer my question.

Best Regards,

Old 02-05-2007, 06:29 AM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Two things to keep in mind:

1. Bash doesn't have a "fork" directive.
2. The sleep command in bash is in terms of seconds, not milliseconds. Sleep t*60*60*1000 will sleep 1000*t hours.

Try this:

~/gphone -c &
../../routing_protocol &
../../monitor_program &
sleep t*60*60
jobs -p > temporary_file
kill $(cat temporary_file)
Hope this helps.
Old 02-05-2007, 06:56 AM   #3
Registered: Sep 2006
Posts: 31
Blog Entries: 1

Original Poster
Rep: Reputation: 15


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass command-line parameter to shell script? Kropotkin Linux - Newbie 12 07-25-2011 09:24 AM
linux bash - how to use a dynamic parameter in shell parameter expansion expression nickleus Linux - General 2 08-21-2006 04:54 AM
writing a shell script tchoua Linux - General 8 02-24-2005 06:18 PM
help writing shell script np complete Linux - Newbie 6 08-30-2004 09:43 PM
How to change parameter values of a function in shell script? Bassam Programming 0 01-25-2004 09:52 AM > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration