Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: telnet from a cisco telnet

by wfsp (Abbot)
on Aug 09, 2011 at 08:53 UTC ( #919421=note: print w/replies, xml ) Need Help??


in reply to telnet from a cisco telnet

Host=>'$ip'
Are you sure that's right? Does removing the single quotes help?

Replies are listed 'Best First'.
Re^2: telnet from a cisco telnet
by Kumar Mantri (Novice) on Aug 09, 2011 at 11:50 UTC

    i made some changes,it worked without errors but i got this output "command timed-out at C:\Users\Kumar\telnet.pl line 7" where did i go wrong?

    use strict; use Net::Cisco; use Net::Telnet(); my $t =Net::Telnet::Cisco->new(Host=>'10.0.0.1'); my @output=0; $t->login('9190','KUM@R425'); $t->cmd("telnet 192.168.203.23"); $t->waitfor('/:$/i'); $t->cmd("public"); $t->waitfor('/>$/i'); @output=$t->cmd("show system"); open(CONFIG,">config.txt"); print CONFIG "@output\n"; close(CONFIG); $t->close;

      yes finally i did with this..done!!but small problem,here it is writing value 1 to the text file..but declared it as array ..here im expecting some set of commands from the device.....any help please?

      use Net::Cisco; my $t =Net::Telnet::Cisco->new(Host=>'10.0.2.2'); my @output; my $tl=0; $t->login('9190','KUM@R425'); $t->print("telnet 192.168.203.23")or $tl=1; $t->waitfor('m/password:/'); $t->print("public"); $t->waitfor('m/]>/'); @output=$t->print("show system"); $t->waitfor('m/]>/'); $t->print("exit"); open(CONFIG,">config.txt"); print CONFIG "@output\n"; close(CONFIG); $t->close;
        @output=$t->print("show system"); $t->waitfor('m/]>/');

        This cannot work, because the output of show system will only be available after you have assigned it into @output. You will need to use $t->cmd(...) to collect the output of a command.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://919421]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2016-12-04 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (61 votes). Check out past polls.