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

i am working on a script with Net::Telnet and whenever i uncomment my adjustment to the Errmode directive all instances of the object immedately generate errors and go strait into it, but when i use the default the exact same input succeeds.
also, when commented out the logfile is generated, but when it is in (my change to Errmode) the logfile is not written to or generated.
here is the relavent code snippet
telnet_login($username,$password,$host,\$telnet); ...... sub telnet_login { use Net::Telnet; my ($username, $password, $host, $telnet) = @_; my $error_msg= "Incorrect username or password, please try again"; $$telnet = new Net::Telnet (Timeout=>7, # Errmode=>\&report_error($error_msg)); ####the above line is the one spoken of in my description############# +####### $$telnet->dump_log("./Plog.log"); # generate log $$telnet->open(Host=>$host); $$telnet->login($username,$password); } .......... sub report_error { my $thing = shift; print $thing; die; }

jcpunk

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

Replies are listed 'Best First'.
Re: Net::Telnet, Errmode problem
by JamesNC (Chaplain) on Jun 19, 2003 at 20:52 UTC
    docs say ErrorMode needs a coderef:
    try something like this....
    $$telnet = new Net::Telnet( Timeout=>7, Errormode=> sub { &report_error($error_msg); }, ) or die "Bang, ya got me...$!";
    I think you need to set your prompt too BTW...
      thank you for the help
      jcpunk

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

OT: Net:SSH
by neilwatson (Priest) on Jun 19, 2003 at 19:55 UTC
    Not to sound like a broken record but, why would you not use Net::SSH or something similar? Clear text passwords are just scary.

    Neil Watson
    watson-wilson.ca