spickles has asked for the wisdom of the Perl Monks concerning the following question:
Cheers, Pickles############# CONNECT TO THE SWITCH AND UPDATE THE CONFIG FILE ####### +################################## my $tftp_server = "172.16.0.100"; my $switch = "172.16.1.2"; my $user = "Cisco"; my $password = "Cisco"; my $dest_file = "startup-config"; my $copy_tftp = "copy tftp start\n$tftp_server\n$config_file\n$dest +_file\n"; #my $matchop = $obj->prompt('/(?m:^\s*--More-- or \(q\)uit/'); # \s matches a whitespace # \S is a negated \s and matches any non-whitespace character [^\s] # ? indicates to match 1 or 0 times, and is placed after the characte +r to match # ^ indicates to match at the beginning of the line # $ indicates to match at the end of the line my $session = Net::Telnet::Cisco->new( Host => $switch, Input_log => "input.log", Output_log => "output.log", Timeout => 30); $session->always_waitfor_prompt; $boolean = $session->ignore_warnings; $boolean = $session->ignore_warnings($boolean); # Wait for the username prompt and enter username @out = $session->waitfor('/Username:.*$/'); print "@out<br>\n"; @out = $session->print($user); print "@out<br>\n"; # Wait for the password prompt and enter the password @out = $session->waitfor('/Password:.*$/'); print "@out<br>\n"; @out = $session->print($password); print "@out<br>\n"; @out = $session->cmd("copy tftp start\n$tftp_server\n$config_file\n$de +st_file\n"); print "@out<br>\n"; @out = $session->cmd("delete vlan.dat\n\n\n"); print "@out<br>\n"; @out = $session->cmd("reload\n\n"); print "@out<br>\n"; @out = $session->close; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net Telnet Cisco
by NetWallah (Canon) on Jul 22, 2008 at 16:11 UTC | |
by spickles (Scribe) on Jul 22, 2008 at 16:16 UTC | |
|
Re: Net Telnet Cisco
by jettero (Monsignor) on Jul 22, 2008 at 16:45 UTC | |
by spickles (Scribe) on Jul 22, 2008 at 17:18 UTC | |
by spivey49 (Monk) on Jul 22, 2008 at 18:17 UTC | |
by karavelov (Monk) on Jul 22, 2008 at 18:51 UTC | |
by Anonymous Monk on Jul 18, 2012 at 16:25 UTC | |
by spickles (Scribe) on Jul 24, 2008 at 02:24 UTC | |
by spickles (Scribe) on Jul 22, 2008 at 18:11 UTC |