[Gloucs] shell script
Guy Edwards
gloucs at mailman.lug.org.uk
Fri Dec 20 00:33:00 2002
Hi
On Thu, 2002-12-19 at 23:31, Will Roe wrote:
> Although, you do a sleep 10 after the process has finished starting
> which is a bit pointless, the command after 'ls' won't be executed
> until 'ls' has terminated. You would have to do 'ls &' to detach
> that process from the script.
Yes quite right,
> Keep us informed as to if it works (and what the hell it's for)
> I assume it's some sort of stress testing??
Yep, just got a copy of "Software Testing", Ron Patton, SAMS 2000
(really good book) I was trying to write a crude script to try and break
a beta program in different ways.
> > > opens="0" // set the value of opens to 0
> > opens=0
Yep spotted that just after I posted
> > > $$=$current // store its process ID
> > current=$$
Believe me when I say Doh! I should have spotted that. The other two
changes I wouldn't have worked out so cheers for that. (cheers mick too)
Looking it up I see -lt stands for less than. Must be getting my
languages mixed up.
> > If that doesn't work, I'll eat my cat...oh sorry...hat ;)
It works but the process isn't killed. Would you like some tomato sauce
on that cat? :-)
I get this kind of output:
(~)> ./testscript.sh
Starting Run
./testscript.sh: line 18: =25213: command not found
kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or
kill -l [sigspec]
Program has been run 1 times
./testscript.sh: line 18: =25216: command not found
kill: usage: kill [-s sigspec | -n signum | -sigspec] [pid | job]... or
kill -l [sigspec]
Program has been run 2 times
./testscript.sh: line 18: =25219: command not found
It's not echoing the PID correctly. This is my current code:
-------------
#!/bin/bash
echo "Starting Run"
opens=0
while [ $opens -lt 5 ] ; do
viewer &
$proID=$!
sleep 10
kill $proID
opens=$(($opens+1))
echo "Program has been run $opens times"
done
--------------
doing
kill $!
instead of kill $proID didn't work,
nor did putting gaps in
$proID = $!
(~)> ./testscript.sh
Starting Run
./testscript.sh: line 18: =: command not found
Guy