The shell we are using, bash, is a updated version of the original Unix shell, called "sh". All Unix shells have their own 'language' that can make doing some complicated tasks rather simple. For example, the for command in bash can be used to repeat a command or a set of commands multiple times, each time with different input data.
Consider the following command:
for q in 10 20 50 100 200 500 1000 2500; do rr /dev/null 25 10 7 3 1 $q; done
If you type this in exactly as it appears here and press RETURN, you will see the output of eight different runs of the rr program; once for each of the different time quanta listed between the for statement.
Try doing that in VMS, MS Windows or the Macintosh!
One of the really nifty things about Unix is ability to pipe the output of one program into another program. One of the major complaints about Unix is that it is terse. While this is true, there is a reason for it. By using programs that don't print a lot of labels around data they output, it is easier to use that data as input to other programs.
Pipes can be used if we want to format the data a little more nicely. Of course, this presumes that you know about Unix programs that let you format data, etc.; I encourage you to learn about them! Assuming that you do know about the "awk" program, you can create a script file (like a VMS command procedure) that a lot of nice things for you.
The following code, if placed in a executable script file, will produce nicely formatted output from the run, including the input data used.
#!/bin/bash
EXE="rr"
LOG="/dev/null"
SIM_TIME="25"
N_PROC="10"
IO_PROC="7"
CPU_PROC="3"
CPUTIME="1"
echo " SEC NPRC IO CPU LIFE QUANT THRPT Credits Penalties Perf"
echo "---- ---- ---- ---- ---- ----- ----- ---------- ---------- ------"
for q in 10 20 50 100 200 500 1000 2500
do
RES="`$EXE $LOG $SIM_TIME $N_PROC $IO_PROC $CPU_PROC $CPUTIME $q`"
echo "$SIM_TIME $N_PROC $IO_PROC $CPU_PROC $CPUTIME $q $RES" |\
awk '{printf "%4d %4d %4d %4d %4d %5d %5d %10.4f %10.4f %6.2f\n", \
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10}'
done
|
If you want to try this, feel free to download the script rr.sh (shift-left click in Netscape) and try it. After you download it, be sure and change the script's permissions so that it is executable: chmod 755 rr.sh should do it. Of course, the output from this script can be redirected -- you can record the data of your run with a command like
rr.sh > rr.data
You can find out more about the awk program by reading it's man page.