nmorenod has asked for the wisdom of the Perl Monks concerning the following question:
Hi all!
I am using the Expect module to establish and manage an ssh connection to execute some commands and read the answer from a server.
Up to the moment, my script executes a fixed list of commands. I've been using a hard-coded list of commands or a file containing the list.
But now I need to add commands to the list during run time. Furthermore, the program should know immediately if a new command has arrived and execute it (if there weren't other commands waiting). And it should not stop listening to the ssh connection while waiting for these new commands. Commands that come from another Perl process in the same computer.
So I need IPC to allow the Expect-running process to get and immediately detect new commands; while at the same time this Expect-running process is expecting on the ssh shell.
My first question is: Which kind of IPC should I use to transmit the new commands? Maybe a pipe? a socket?
I guess there are more than one valid way to do that... but recommendations are welcome!
The second question is: How can I achieve the coordination?
I read that Expect may listen to multiple process at the same time. So maybe there is a way to establish a pipe or similar from the process that sends new commands to the Expect-running process, and make the last use Expect on that pipe to get the new commands (at the same time it is expecting on the ssh shell). But I'm not sure whether Expect may work also with pipes (or filehandles in general) or if it works only with commands.
In case that can't be done, which is the best way (compatible with Expect) to communicate between processes that a new command is ready on the list.
Thanks in advance and sorry for the long text!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inter-process communication when using Expect.pm
by Illuminatus (Curate) on Mar 12, 2010 at 14:18 UTC | |
|
Re: Inter-process communication when using Expect.pm
by ssandv (Hermit) on Mar 12, 2010 at 17:28 UTC |