Page 1 of 1

help needed: passing arguments to a test a perl script

Posted: Sat Mar 13, 2004 12:36 pm
by sh33p1985
im quite new to php and i have no idea how to do this.

in the context of my problem, i have basic calculator written in perl with 4 operators + - * /. 2 txt fields (first number seocnd number) and a drop down menu (with the 4 operators as options) are displayed on a webpage and when the user clicks calculate it will bring up a new page with the answer(assuming the the input is valid).

i need to write a peice of code in php the will test the perl script (i.e each operator using valid input) to see if it functions. im guessing i will need to pass arguments to the script in order to do this but i really am stuck on how to do this.

any help to get me started or more would be much appreciated.
thanks

Re: help needed: passing arguments to a test a perl script

Posted: Sat Mar 13, 2004 11:26 pm
by TheBentinel.com
sh33p1985 wrote: i need to write a peice of code in php the will test the perl script (i.e each operator using valid input) to see if it functions. im guessing i will need to pass arguments to the script in order to do this but i really am stuck on how to do this.
How about using file_get_contents?

$output = file_get_contents("http://yourserver.com/calc.pl?operator= ... perand2=20");
print ($output); // should print 35

You could randomize the operands or just have a series of these to run your tests.

Is that the kind of thing you're looking for, or have I missed your point?

Posted: Sun Mar 14, 2004 5:14 am
by sh33p1985
no, actually that makes sense, seeing as the php will be testing lots of similar scripts just have to force the scripts,textfields,and operator selection to have specific names.thanks ill give it a go today and see what i come up with!