Loading ...
Sorry, an error occurred while loading the content.

Perl/Expect

Expand Messages
  • Thomas George Simon
    Hello Folks, I m trying out this script for expect module in perl and somehow not able to figure out why its not working : #!/usr/bin/perl -w use Expect; our
    Message 1 of 3 , Jul 25, 2007
    • 0 Attachment
      Hello Folks,
      I'm trying out this script for expect module in perl and somehow not
      able to figure out why its not working :

      #!/usr/bin/perl -w
      use Expect;

      our $scp = new Expect;

      $scp = Expect->spawn("ssh username\@123.123.123.123") or
      die "Cannot ssh: $!\n";
      $scp->expect(20,'-re',".*assword: ") or
      die "did not ask for password\n";
      $scp->send("my_password\r") or
      die "did not detect password";

      $scp->soft_close();

      The first two commands work, but the third one fails.

      I am able to ssh manually outside the script.

      Could someone tell me what is wrong ?

      Thanks.
      Thomas.
    • Peter L. Berghold
      ... Hash: SHA1 ... How is it failing? What sort of error(s) are you seeing? For what it is worth, you might look at using Net::SSH::Expect instead of Expect
      Message 2 of 3 , Jul 25, 2007
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        Thomas George Simon wrote:
        >
        > The first two commands work, but the third one fails.
        >
        >


        How is it failing? What sort of error(s) are you seeing?


        For what it is worth, you might look at using Net::SSH::Expect instead
        of Expect for this particular application. I've used it a lot with a
        great deal of success.


        - ----

        Peter L. Berghold Unix Professional
        Peter@... AIM: redcowdawg YIM: blue_cowdawg
        "Those who fail to learn from history are condemned to repeat it."
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.5 (GNU/Linux)
        Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

        iD8DBQFGp2cIUM9/01RIhaARAjk1AJ41qzDmOlbCJ14f01JO2SSiK6Z+KQCdFSNd
        yZIM+5c2Hh/Lo45OAkl+vh8=
        =y668
        -----END PGP SIGNATURE-----
      • Thomas George Simon
        Thank you for the response. It goes to the die statement for the third command : did not detect password at I think I should start using the Net::SSH module.
        Message 3 of 3 , Jul 25, 2007
        • 0 Attachment
          Thank you for the response.
          It goes to the die statement for the third command :
          did not detect password at

          I think I should start using the Net::SSH module.
          But this looked simple enough. I just wanted to understand
          why it would not work.

          Thanks again.

          --- In perl-beginner@yahoogroups.com, "Peter L. Berghold" <peter@...>
          wrote:
          >
          > -----BEGIN PGP SIGNED MESSAGE-----
          > Hash: SHA1
          >
          > Thomas George Simon wrote:
          > >
          > > The first two commands work, but the third one fails.
          > >
          > >
          >
          >
          > How is it failing? What sort of error(s) are you seeing?
          >
          >
          > For what it is worth, you might look at using Net::SSH::Expect instead
          > of Expect for this particular application. I've used it a lot with a
          > great deal of success.
          >
          >
          > - ----
          >
          > Peter L. Berghold Unix Professional
          > Peter@... AIM: redcowdawg YIM: blue_cowdawg
          > "Those who fail to learn from history are condemned to repeat it."
          > -----BEGIN PGP SIGNATURE-----
          > Version: GnuPG v1.4.5 (GNU/Linux)
          > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
          >
          > iD8DBQFGp2cIUM9/01RIhaARAjk1AJ41qzDmOlbCJ14f01JO2SSiK6Z+KQCdFSNd
          > yZIM+5c2Hh/Lo45OAkl+vh8=
          > =y668
          > -----END PGP SIGNATURE-----
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.