On Sat, 12 Feb 2005, perl perl wrote:

> 
> Question2: :-)
> How do you implement the Expect script above into Perll? Are there
> several modules to choose from?

Here is a little admin script I run from time to time which might explain
the use of Perl's expect (Yes..I know, no use ofstrict or warnings)
--------------------------------------------------------
#!/usr/bin/perl

use Expect;

[EMAIL PROTECTED];$end=$ARGV[1];

if ((!defined($ARGV[0])) or (!defined($ARGV[1])))
{print "\n Usage: perl req.pl START_Nr END_Nr\n\n";exit}

for ($i=$start;$i<=$end;$i++)   {

$command = Expect->spawn("/usr/local/bin/req -kill $i") or die "Can'r
Expext$!\n";

unless ($command->expect(10,  -re => "[y/n]"))
        {
print "timed out\n";
        }else
        {print $command "y\r";
        }
                                }

------------------------------------------------

So the module is called Expect, see your local CPAN site for that.

As far as I can see, it mimics the tcl expect.


>From the documentation;

     Expect.pm is built to either spawn a process or take an
     existing filehandle and interact with it such that normally
     interactive tasks can be done without operator assistance.
     This concept makes more sense if you are already familiar
     with the versatile Tcl version of Expect. 

        There are some 30 public functions
        There are 7 programmable variables

perldoc Expect will give you all the gory detail.





Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to