external program

A

Alex Lee

Dear all: I am having a problem that is driving me nuts and I hope some
one can help me.

Basically I need to access another program/script from my perl script.
This is easy. It is not when the program ask for an input (ie yes or
no).

here is an example:
------------------------------------
-- external script
$|=1;
print "enter something \n";
my $i = <>;
print "your input: $i";
-------------------------------------

-- my script:
open(TE, "perl externalScript.pl|") or die "no";
while(<TE>){
print "$_";
### need to print "hello world \n\r" when $_ =~ /enter/;
}

---------------------------------------
basically I need the external program to accept my input:
example: print "hello world \n\r" when $_ =~ /enter/;

I tried many different ways, but none works so far. I figure that is
probablt has something to do with redirecting my STDOUT from my script
to the external program. How I do not know. If anyone can help, it
would be greatly apprecaited.

thanks.
 
P

Paul Lalli

Alex Lee said:
Basically I need to access another program/script from my perl script.
This is easy. It is not when the program ask for an input (ie yes or
no).

here is an example:
------------------------------------
-- external script
$|=1;
print "enter something \n";
my $i = <>;
print "your input: $i";
-------------------------------------

-- my script:
open(TE, "perl externalScript.pl|") or die "no";
while(<TE>){
print "$_";
### need to print "hello world \n\r" when $_ =~ /enter/;
}

Have a look at the Perl FAQ on this topic:

perldoc -q pipe
"How can I open a pipe both to and from a command?"

Paul Lalli
 
J

Jürgen Exner

Alex said:
Dear all: I am having a problem that is driving me nuts and I hope
some one can help me.

Basically I need to access another program/script from my perl script.
This is easy. It is not when the program ask for an input (ie yes or
no).

You may want to check the Expect module

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top