Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > external program

Reply
Thread Tools

external program

 
 
Alex Lee
Guest
Posts: n/a
 
      09-15-2004
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.

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      09-15-2004

"Alex Lee" <(E-Mail Removed)> wrote in message
news:ci9pt8$(E-Mail Removed)...
> 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/;


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


 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      09-15-2004
Alex Lee wrote:
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: CGI won't run external program - Expect - ans'ed my own question chuck Firefox 0 11-15-2005 12:00 AM
Create references to external scipt files from within an external script file Mellow Crow Javascript 6 11-04-2005 01:16 PM
CGI won't run external program - Expect chuck Firefox 0 07-30-2005 03:44 PM
unresolved external symbol/using an external dll Scott Allen C++ 8 05-02-2004 06:11 PM
Invoking an external program in ASP.NET Nibha Kothari ASP .Net 0 07-22-2003 09:03 PM



Advertisments