jcpunk has asked for the wisdom of the Perl Monks concerning the following question:

I am rather stuck on a Net::Telnet problem, and since I am a bit high on cough syrup I cannot locate the solution.
The problem I am encountering is this script is supposed to change passwords and as the log shows it does not send out any thing at all beyond passwd
> 0x00000: 2f 62 69 6e 2f 70 61 73 73 77 64 0d 0a /bin/pa +sswd.. < 0x00000: 2f / < 0x00000: 62 69 6e 2f 70 61 73 73 77 64 0d 0a 70 61 73 73 bin/pas +swd..pass < 0x00010: 77 64 3a 20 20 43 68 61 6e 67 69 6e 67 20 70 61 wd: Ch +anging pa < 0x00020: 73 73 77 6f 72 64 20 66 6f 72 20 70 72 69 65 68 ssword +for prieh < 0x00030: 65 63 6b 0d 0a eck.. < 0x00000: 45 6e 74 65 72 20 6c 6f 67 69 6e 28 4e 49 53 2b Enter l +ogin(NIS+ < 0x00010: 29 20 70 61 73 73 77 6f 72 64 3a 20 ) passw +ord:
the relivent code snipit is
$telnet->dump_log("log.log"); $telnet->cmd($PASSWD) or report_error("ERROR", "No password prompt + found, contact Information Technologies: "); $telnet->waitfor('/password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: "); $telnet->print($password); $telnet->waitfor('/password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/changed/');
in addition to not sending passwords out it also does not call the  report_error function found after the or and instead uses the default error action (which I have changed to call report_error rather then die) i am assuming this is a timeout which calls this error, however, why is it not calling the or statement?

i cannot determine what is going on in this, might i enlist some aid.
jcpunk

by the way thanks for all the help that was, is, and will be

Replies are listed 'Best First'.
Re: telnet, passwords, and other challenges to my cough syrup ridden mind
by phydeauxarff (Priest) on Jun 30, 2003 at 15:15 UTC
    ....rather than recreating the wheel, I will point you to a previously published solution here it appears to change both NT and Unix passwords but I suspect you can just strip out what you need, modifying the  waitfor() to account for your prompts.

      thank you very much for that, it is apprecated
      jcpunk

      by the way thanks for all the help that was, is, and will be

Re: telnet, passwords, and other challenges to my cough syrup ridden mind
by naChoZ (Curate) on Jun 30, 2003 at 14:55 UTC
    First, obligitory advice, doing this over telnet... bad idea.

    Anyway, remember, the password prompt displayed is sent to STDERR not STDOUT, so that may be tripping you up.

    ~~
    naChoZ

      i apprecate the standard anti clear text passwords stance that everyone holds except my superiors, but i cannot just do what i want. i will look into the stderr thing and see if i can make that work thanks
      jcpunk

      by the way thanks for all the help that was, is, and will be

Re: telnet, passwords, and other challenges to my cough syrup ridden mind
by bbfu (Curate) on Jun 30, 2003 at 17:05 UTC

    Regarding the report_error issue, I'm not sure what you mean when you say that you "have changed [Net::Telnet] to call report_error rather than die." You need to do the following, just after creating the $telnet object:

    $telnet->errmode('return');

    This tells Net::Telnet to return an undef value on failure, instead of calling the default, or a custom, error handler (and dying).

    bbfu
    Black flowers blossom
    Fearless on my breath