Thanks, o wise rodent.   8^)   Changing the waitfor() to refer to $cs (as you and archon both suggested) got rid of the object error.

I've added "$dump_log=>setpassCat.dumplog" to "my $cs =".   With a bit of luck, perusing the dump_log and input_log should help me work out remaining problems.
    cheers,
    Don
    striving for Perl Adept
    (it's pronounced "why-bick")

Update: It's still quite kludgy, but the following scriptlet *does* work.   8^D   The next order of business is to replace the or die's with if(){} for all the $cs -> sections, so Net::Telnet can deal directly with timeouts and such.   I expect to then find that the waitfor()</t>'s need further tweaking.

#!/usr/bin/perl -w # setpassCat.pl # February 26-27, 2001 use strict; use Net::Telnet::Cisco; my $target = ''; my $oldpass = ''; my $olden = ''; my $newpass = ''; umask oct 177; my $cs = Net::Telnet::Cisco->new ( host =>"$target", errmode =>'return', timeout =>'30', input_log =>'setpassCat.inlog', ) or die " Error connecting +to $target: $!"; $cs->login('',$oldpass) or die " Error logging in +to $target: $!"; print $cs -> last_prompt, "\n"; $cs->enable($olden) or die " Error getting pri +vilaged mode at $target: $!"; print $cs -> last_prompt, "\n"; my @cmd_output = $cs->cmd('set pass'); print (@cmd_output) or die "Error giving \"set +pass\" command: $!"; print $cs -> last_cmd, "\n"; $cs ->waitfor('/Enter old password: /') or die "Error getting \"Ent +er old password\" prompt: $!"; print $cs -> last_prompt, "\n"; @cmd_output = $cs -> cmd($oldpass); print (@cmd_output) or die "Error giving \"old +password\": $!"; $cs ->waitfor('/Enter new password: /') or die "Error getting \"Ent +er new password\" prompt: $!"; print $cs -> last_prompt, "\n"; @cmd_output = $cs -> cmd($newpass); print (@cmd_output) or die "Error giving \"new +password\": $!"; $cs ->waitfor('/Retype new password: /') or die "Error getting \"Ret +ype new password\" prompt: $!"; print $cs -> last_prompt, "\n"; @cmd_output = $cs -> cmd($newpass); print (@cmd_output) or die "Error giving \"Rety +pe new password\": $!"; $cs ->waitfor('/Password changed./') or die "Error getting \"Pas +sword changed\" statement: $!"; print $cs -> last_prompt, "\n"; @cmd_output = $cs -> cmd('disa'); print (@cmd_output) or die "Error leaving privi +laged mode: $!"; print $cs -> last_prompt, "\n"; $cs -> close;

In reply to Re: (2) Net::Telnet and waitfor() (Woo-hoo!!) by ybiC
in thread Net::Telnet and waitfor() by ybiC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.