in reply to Re: How do I get expect.pm to ignore special characters?
in thread How do I get expect.pm to ignore special characters?

Thank you sn1987a,

Success!, My script can now send and expect from a file and push that to an array. Thank you so very much again now I just need a little more help on how to get my script to make a list of which password resets failed from each list.

  • Comment on Re^2: How do I get expect.pm to ignore special characters?

Replies are listed 'Best First'.
Re^3: How do I get expect.pm to ignore special characters?
by FreeBeerReekingMonk (Deacon) on Apr 15, 2015 at 20:08 UTC

    Well you could return values:

    $ssh->expect(5, '#') or return "ERROR"

    You can also lower the amount of timeout, 60 is ok while you make the initial handshake connection, but you must have a WAN if you need to wait 60 seconds for the other prompt. Any way; and at the end of the subroutine:

    return "OK"; }

    Then in your main loop, you pick that value up:

    for my $server (@servers) { # do your thing with $server $rc = change_password($server); if($rc eq "ERROR"){ die "PANIC for $server"} }
Re^3: How do I get expect.pm to ignore special characters?
by sn1987a (Curate) on Apr 15, 2015 at 19:50 UTC

    Modify change_password to return a status, true(1) if it succeeded or false(0) otherwise. Then check the return value in the main loop:

    my @fail_servers; for my $server (@servers) { # do your thing with $server push @failed_servers, $server unless change_password($server); }

      Hello friend sn1987a and all,

      I had been away sick with really bad hay fever and since I live in Oklahoma City its even worse here. But I had wanted to come back to this perl script you had been very helpful with me and tell you that everyone's feedback and suggestions have been regarded with very much gratitude. I need to review what I have and where I want it to go.

      Regards,

      "Pergratum habeo"

      Andreas Magana "The Spaniard"