Perl: connect to network devices, run set of commands
I am trying to write a script for my own use that will allow me to connect to network devices, then run a set of commands.
I start with a list of ips in a text file. Each ip is on its own line.
I start with a second file of commands. Each command on one line.
for illustration .. the cmd.txt file exists and has the following commands resident
sh ver
sh run
Using Net::OpenSSH
Partial output example from Net::OpenSSH
Quote:
Cisco CISCO829951/K9 (revision 1.1) with 995328K/53248K bytes of memory.
Processor board ID FTX1641ALBP
4 Gigabit Ethernet interfaces
1 Serial interface
2 terminal lines
1 Virtual Private Network (VPN) Module
2 Voice FXO interfaces
24 Voice FXS interfaces
1 Internal Services Module (ISM) with Services Ready Engine (SRE)
Cisco Unity Express 8.6.4 in slot/sub-slot 0/0
DRAM configuration is 72 bits wide with parity enabled.
255K bytes of non-volatile configuration memory.
250880K bytes of ATA System CompactFlash 0 (Read/Write)
License Info:
License UDI:
-------------------------------------------------
Device# PID SN
-------------------------------------------------
*0 CISCO2951/K9 FTX1641ALBP
Technology Package License Information for Module:'c37851'
-----------------------------------------------------------------
Technology Technology-package Technology-package
Current Type Next reboot
------------------------------------------------------------------
ipbase ipbasek9 Permanent ipbasek9
security securityk9 Permanent securityk9
uc uck9 Permanent uck9
data None None None
Configuration register is 0x2102
Connection to 10.1.1.3 closed by remote host
I also tried to get Net::SSH2 to work
Partial output example from Net::SSH2
Quote:
This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.
If you require further assistance please contact us by sending email to export@cisco.com.
Cisco CISCO37951/K9 (revision 1.1) with 995328K/53248K bytes of memory.
Processor board ID FTX1645AL9S
4 Gigabit Ethernet interfaces
1 Serial interface
2 terminal lines
1 Virtual Private Network (VPN) Module
2 Voice FXO interfaces
24 Voice FXS interfaces
1 Internal Services Module (ISM) with Services Ready Engine (SRE)
Cis
Use of uninitialized value $_ in die at m2 line 37.
Died at m2 line 37.
The output for both are very similar. I get the first command response but not the second.
Hi
I am very well aware of configuring central logging (syslog)server on solaris to capture logs of other solaris servers. But don't know how to capture the logs of network devices like Juniper , cisco etc on solaris server. Is this possible through syslog server of solaris. Is there any way we... (1 Reply)
Hi All,
Can someone help me in finding out below information from ReHat linux,Solaris,AIX, hp-ux machine :
1. How to find total number of ports in supported by each slot.
2. name of ports that are used to transmit data to the printer
3. total number of slots on a network device (2 Replies)
I have a perl script that is called with a router name command list file and output file. The command file can be very large, up to 3k of commands. At first I dumped the command list file to an array and ran the entire file on the router and captured the output. It worked ok for a command list in... (1 Reply)
Hello, I need to write a program which sets server's ip address, router, network mask. Program also should set if it is an internal or external ip. Maybe someone can help me ? Any information from u is very useful :b:
I stopped at .. :(
#!/bin/sh
A=`hostname -i`
echo "server ip address is $A"... (4 Replies)
Hi,
Can anyone please correct the script such that it run on all the devices in the devicelist.txt file.
The problem is when the script runs it only reads the first device in the list, configures the device and exists.
Script:
The devicelist.txt:
device.crs... (1 Reply)
Hi
Please help me to resolve.
Question:
I can run this command to change the mode of a device with id=500 as below
dbc "select device mode=3 where id=500;"
How can i run the same query with a file contaning n number of ids ?
file1.txt
12
234
34
500
34
45
Thanks in... (3 Replies)
I am getting the error "Can't call method "prepare" on an undefined value at..." with the following code:
<code>my %dbh;
my $dbh = DBI->connect("DBI:mysql:Customer_Data",
$username,
$password
) or die "Database connection... (1 Reply)
While I know that it's possible to use something like SANE to share a USB scanner over a network, or use NBD or iSCSI to share a USB flash or external HD over the network, I've been wondering about a raw USB <--> TCP/IP transport. Back in the late 90s, I swear I remember hearing about a project... (2 Replies)
I need to run a set of commands on a remote machine using ssh. it should also collect output and return status of each command. Can someone help me how to do this? (1 Reply)
After installing an internal fax modem I get the message above when using the cu -l /dev/tty1A command.
Any help would be most appreciated to the cu command to work again. Thanks. (3 Replies)