Passing a command to a process that's already running

K

Keith

I want to be able to use perl to open a program and then pass a command
to it.

The program is links which is a text-based browser. After openning a
webpage I want to be able to pass a command to the browser. What perl
command do I use in this case?

If I use exec("links www.foo.org") to open the links browser, I can't
pass a command to it since the script stops working.

If I use system(("links www.foo.org") the perl script stops and I
cannot progress forward until I manually close the links applicatioon.


Any help here?
 
J

Josef Moellers

Keith said:
I want to be able to use perl to open a program and then pass a command
to it.

The program is links which is a text-based browser. After openning a
webpage I want to be able to pass a command to the browser. What perl
command do I use in this case?

If I use exec("links www.foo.org") to open the links browser, I can't
pass a command to it since the script stops working.

If I use system(("links www.foo.org") the perl script stops and I
cannot progress forward until I manually close the links applicatioon.


Any help here?

You might want to look at "expect". Originally built on top of Tcl,
there is a perl implementation. See CPAN for details.
 
A

Anno Siegel

Keith said:
I want to be able to use perl to open a program and then pass a command
to it.

The program is links which is a text-based browser. After openning a
webpage I want to be able to pass a command to the browser. What perl
command do I use in this case?

If I use exec("links www.foo.org") to open the links browser, I can't
pass a command to it since the script stops working.

If I use system(("links www.foo.org") the perl script stops and I
cannot progress forward until I manually close the links applicatioon.


Any help here?

open my $links, '| links' or die "links process start: $!";
print $links 'retrieve something';
print $links 'other command';
close $links or die "links process exit: $?";

See perldoc open.

Anno
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top