Call a test and execute

izzy2018

New Member
Joined
Jun 5, 2018
Messages
2
Reaction score
0
Credits
0
Hi all,

I took Linux 30 yrs and did not use for long time. Now I have to use Linux to test but i have to create a file and add all test like this
<CODE>
runtest.pl test.js -forcetestname OneA
#runtest.pl test.js -forcetestname OneB
#runtest.pl test.js -forcetestname OneC
#runtest.pl test.js -forcetestname OneD
#runtest.pl test.js -forcetestname OneE
</CODE>
How do we write a simple shell code to call like
Runit.sh OneA then it will run
runtest.pl test.js -forcetestname OneA
Runit.sh OneD
then it will run
runtest.pl test.js -forcetestname OneD
So i donot have to REM test i already run and unREM to run next test ?
I know it should be simple and hope you can show me how .
Thanks
 


I think i can do it
#!/bin/sh
echo "What test you run:"
read TESTNAME
echo "Start $TESTNAME"
runtest.pl test.js -forcetestname $TESTNAME
 
That would be one way to do it.

To run it the way you wanted in your post:
E.g.
runit.sh OneA

You can modify your runit script to work with parameters:
Code:
#!/bin/sh

if [ $# -eq 1 ] ; then
  echo "Starting test $1"
  runtest.pl test.js -forcetestname "$1"
fi

In the above script, $# is the number of parameters the script received from the command line.

In shellscripts, parameters are automatically stored in variables starting from $0 - which is actually the name of the script. $1 is the first parameter, $2 is the second parameter and so on!
So if you passed 10 parameters, your 10th parameter would be stored in $10.
There are also some special variables like $# (which I have already explained) and $@ which is basically the entire command string that was used to invoke the script.

Anyway - the above script checks that we have exactly one parameter. If we did get one, then its value is used as the name of the test to run.
And if we got more than one, or none at all - the script will do nothing!
 

Members online


Latest posts

Top