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

ok, this may be the cough syrup talking, but i cannot make my Net::Telnet object work for changing passwords. i have reviewed the documentation and while there is an 'example' provided it does not actually implement telnet just a weird way of interfacing with the passwd program and whenever i run my code it leaves behind zombie processes, which is not cool, so does anyone have any idea how to make this code actually work
$PASSWD = "/bin/passwd"; $telnet->cmd($PASSWD) or report_error("ERROR", "No password prompt fou +nd, contact Information Technologies: "); $telnet->waitfor('/password: ?$/i') or report_error("ERROR", "No passw +ord prompt found, contact Information Technologies: "); $telnet->print($password); $telnet->waitfor('/new password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/new password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: "); $telnet->print($new_password); $telnet->waitfor('/changed/'); ..... sub report_error { #give out std error message and write error to a log file }

jcpunk

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

Replies are listed 'Best First'.
Re: Net::Telnet and changing passwords
by phydeauxarff (Priest) on Jun 27, 2003 at 18:34 UTC
    My experience is waitfor() seems to be pretty finicky about what is returned....have you tried using dump_log() to verify what is going on?
      yes, i really should have posted that up there as well.... sigh i knew i forgot something
      > 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:
      that is the log, and the waitfor()'s came out of teh documentation letter by letter, but since this currently doesnt work, im up for recoding it... i will add those to my list of lines to be evaluated for dumping.

      but that is beside the point, the program hangs wainting for the password which i thought i told it to send...
      jcpunk

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

        I may be missing something here but aren't you waiting for
        /new password:
        and from what I can see from debug() you are getting
        Enter l+ogin(NIS+ ) password
        I don't think the condition
        $telnet->waitfor('/new password: ?$/i') or report_error("ERROR", "No p +assword prompt found, contact Information Technologies: ");
        Is being met...waitfor() is just sitting there waiting for that prompt to match and it isn't so you never get to
        $telnet->print($new_password);

        Of course, I haven't tried it on a real machine but this looks to me to be the possible cause of your quandry.