Having also done it both ways, think shmem's suggestion to use the Perl Expect.pm module is very good advice.
I wrote an TCL-based Expect script that was called from Perl. I used Proc::Simple to run several copies of the Expect script in parallel with the main Perl process. If you need very limited communications, you can tail a log file or create flag files when you need to check progress.
After doing that and living with it for a few months, I wound up converting the whole thing to the Perl Expect.pm package.
The biggest win is that Expect.pm actually works reliably, which is not true of many versions of TCL-based Expect. There is a discussion of the problem and a patched version of expect on the Rancid site. Even using Shrubbery Network's Expect and TCL, I still saw Expect processes that would hang once in a blue moon.
It's also a lot easier to write complex logic in Perl than in TCL, IMHO. It may be that I'm just more familiar with Perl, though.
Another win is that if your Perl script needs to ask the user for a password, it can pass it securely to a Expect.pm script as an ordinary subroutine parameter. Using TCL Expect, it is tempting to transfer the passwords using a temporary file or an environment variable. Neither of those approaches are particularly safe from prying eyes. You can have the Perl script read the Expect script, plug in the password into the Expect script as a TCL assignment statement, open a pipe to the Expect compiler, and write the Expect script. It's not pretty though, especially when you are trying to track down Expect bugs.
In reply to Re: Perl and Expect Question
by quester
in thread Perl and Expect Problem
by btobin0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |