Mahoota has asked for the wisdom of the Perl Monks concerning the following question:

I have one program that is executed by a simple line written to the command line:
>program -fFileToWriteTo FileToReadFrom
and was wondering how to write a perl script to simply write this to the command line. (I can then get the results by reading in from the results file created, no problem.)

A second program, however, is executed from the command line and then asks for a filename to be entered:

>coils Please enter filename of sequence
Does this require a different kind of script to write into a program?

For this program the results are displayed in the command line (as a list of letters amd probabilities) and not written to a file. How can i read them into my script?

Help on any of the above matters is appreciated, thanks

Replies are listed 'Best First'.
Re: Command Line
by Aristotle (Chancellor) on Jun 23, 2002 at 14:43 UTC

    In case of the first, you can call the program using system().

    In case of the latter, things get tricky - you need a pipe to the program to supply it the filename, but you also need to read its results. A pipe to it could be done using open my $prog, "|program"; print $prog "$filename\n"; Reading its results could be done using backticks as in `program`. To combine both however, you need IPC::Open2.

    Update: (Hours later.) Oopsie. Has to be print $prog "$filename\n"; and not print $prog, "$filename\n"; of course. I'm surprised noone caught else this sooner.

    Makeshifts last the longest.