Passing parameters for a C program in Linux.
pdpinheiro at gmail.com
Tue Jun 30 16:52:10 CEST 2009
On Jun 30, 11:46 am, "venutaurus... at gmail.com"
<venutaurus... at gmail.com> wrote:
> Hi all,
> I have to write an automted script which will test my c
> program. That program when run will ask for the commands. For example:
> local-host# ./cli
> Enter 1 for add
> Enter 2 for sub
> Enter 3 for mul
> 1 -------Our option
> Enter two numbers
> 44 33 -------- Our option
> Result is 77
> As shown in the above example it lists all the options and waits for
> user input and once given, it does some operations and waits for some
> more. This has to be automated.
> Can someone give suggestions how to do this in Python (Linux Platform
> in particular).
> Thank you,
The easiest (and ugliest) way to do this would probably be to write a
file input.txt and a file output.txt with each input/output value, and
then to do this on the command prompt:
./a.out < input.txt | diff output.txt -
this will run a.out (assuming that's your program's name), feed in
input.txt as input, and pipe that into diff to compute the differences
between its output and output.txt
More information about the Python-list