Giter Site home page Giter Site logo

expect.pm's Introduction

Build Status

Expect.pm

Expect requires the latest version of IO::Tty, also available from CPAN. IO::Stty has become optional but I'd suggest you also install it. If you use the highly recommended CPAN module, there is a Bundle::Expect available that installs everything for you.

If you prefer manual installation, the usual

perl Makefile.PL
make
make test
make install

should work.

Note that IO::Tty is very system-dependend. It has been extensively reworked and tested, but there still may be systems that have problems.

Please be sure to read the FAQ section in the Expect pod manpage, especially the section about using Expect to control telnet/ssh etc. There are other ways to work around password entry, you definitely don't need Expect for ssh automatisation!

The Perl Expect module was inspired more by the functionality of Tcl/Expect than any previous Expect-like tool such as Comm.pl or chat2.pl.

The Tcl version of Expect is a creation of Don Libes ([email protected]) and can be found at http://expect.nist.gov/. Don has written an excellent in-depth tutorial of Tcl/Expect, which is Exploring Expect. It is the O'Reilly book with the monkey on the front. Don has several references to other articles on the Expect web page.

I try to stay as close to Tcl/Expect in interface and semantics as possible (so I can refer questions to the Tcl/Expect docu). Suggestions for improvement are always welcome.

There are two mailing lists available, expectperl-announce and expectperl-discuss, at

http://lists.sourceforge.net/lists/listinfo/expectperl-announce

and

http://lists.sourceforge.net/lists/listinfo/expectperl-discuss

Thanks to everybody who wrote to me, either with bug reports, enhancement suggestions or especially fixes!

Dave Jacoby (maintaner of Expect.pm) [email protected]

2015-10-31

expect.pm's People

Contributors

jacoby avatar neilb avatar syspete avatar szabgab avatar yanick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

expect.pm's Issues

rename repo to Expect

Neil pointed out that Perl standard for Github repos is maintainer/Module.

There's lots of small things that need to be changed in the metadata, but shouldn't be too big a change.

sysread() is deprecated on :utf8 handles

I'm upgrading some old hosts and the newer perl is warning from the sysread in interconect() (which looks like it will be an error in perl-5.30).

I've tested with current Expect + IO::Tty and still get the warning.

This hack silences the warning for the version 1.21 that comes with Ubuntu Bionic (the same change but with different offset also silences the warning for 1.35). For my use cases, this replicates the previous behavior, but I suspect it's not the 'right' fix for the module.

--- /usr/share/perl5/Expect.pm	2010-10-17 02:59:29.000000000 +0000
+++ foo/Expect.pm	2020-11-18 17:13:22.422382834 +0000
@@ -1107,6 +1107,7 @@
     # doing something like $temp_mask='' unless defined ($temp_mask)
     # has no effect whatsoever. This may be a bug in 5.001.
     $read_mask = $read_mask | $temp_mask;
+    binmode($handle, ':raw');
   }
   if ($Expect::Debug) {
     print STDERR "Read handles:\r\n";

Incorrect behaviour of Expect in DESTROY regarding to $!

Hello!

We have a legacy system that we are moving to the modern perl from older one and we have some issues with Expect on macos.

As you already mentioned in the DESTROY: https://github.com/jacoby/expect.pm/blob/master/lib/Expect.pm#L1844

$? might be affected by syscall. But the same is true for $!. As been said in perlvar :

When referenced, $! retrieves the current value of the C errno integer variable. If $! is assigned a numerical value, that value is stored in errno. When referenced as a string, $! yields the system error string corresponding to errno.
Many system or library calls set errno if they fail, to indicate the cause of failure. They usually do not set errno to zero if they succeed and may set errno to a non-zero value on success. This means errno, hence $!, is meaningful only immediately after a failure

So it is reasonable to store the $! somewhere and then re-assign but I am not sure if this behaviour is correct and this fix is proper.

However, I can prepare the PR for review if it is ok for you.

Multiline issue regarding index() function when matching ^ and/or $

When using '-re' to match a regex, there is an issue regarding the used index() function and matching ^ or $.

Example (simplified, but represents the code of Example.pm:759-785

my $string = "test\r\ntest-end-test\r\nend";
my $pattern = qr/^end$/m;
if (my @matchlist = ($string =~ m/($pattern)/)) {
    # match successful => the "end" at the end of the string is matched and stored in @matchlist

    # but now you are using index() to determine the position... which will give you the position of the "end" string at "test-end-test", NOT the matched "end" at the end of the string
    my $start = index $string, $matchlist[0];

    # so in the end, $before and $after are wrong
    my $before = substr $string, 0, $start;
    my $after = substr $string, $start + length($matchlist[0]);

    print "Before: $before\n";
    print "After: $after\n";
}

String:

test
test-end-test
end

Output:

Before: test
test-
After: -test
end

Expected output:

Before: test
test-end-test

After:

The code used in v1.25 was not using index() and seems to work as expectd.

@matchlist = ( ${*$exp}{exp_Accum} =~ m/$pattern->[2]()/m );
( $match, $before, $after ) = ( $&, $`, $' );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.