For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > September 2005 > script to run the program









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author script to run the program
a

2005-09-21, 3:56 am

I need to run a program that need input at run time.
Is it possible to simulate this by perl?
Thanx


Josef Moellers

2005-09-21, 3:56 am

a wrote:
> I need to run a program that need input at run time.
> Is it possible to simulate this by perl?
> Thanx
>=20
>=20


It depends.
You can open a pipe to the program and send the input through the pipe=20
(beware of buffering):
open(DST, '|', $program);
print DST "Input\n";

Or look at Perl/Expect.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

Joe Smith

2005-09-26, 3:56 am

Josef Moellers wrote:
> a wrote:
>
>
> It depends.
> You can open a pipe to the program and send the input through the pipe
> (beware of buffering):
> open(DST, '|', $program);
> print DST "Input\n";
>
> Or look at Perl/Expect.


For interactive use (where a line of input depends on something that
was output previously), a PTY-based solution (such as Expect.pm)
is the way to go.
http://search.cpan.org/author/DJERI...-0.02/Simple.pm

-Joe
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com