08-29-2011 02:47 PM - edited 03-07-2019 01:57 AM
is it possible to get the uptime, ios or catos version and version number of all my cisco switches from a script?
08-29-2011 02:56 PM
Yes.
You can easily do with expect which can login on each router/switch, issue the required commands and store the output in the required format in a file.
You can look it up on google and this is the main puprose for which expect was written.
Hope this helps
Fabio
08-30-2011 05:04 PM
this is what i have
#!/usr/bin/expect -f
set timeout 20
set IPaddress x.x.x.x
set Password "xxxxx"
spawn telnet $IPaddress
expect "Password: "
send "$Password\r"
exp_send "sh version\r"
expect "R1#"
exp_send "exit\r"
how do I find what i need and then save to a file for 100s switches
I need
version, uptime, image name, serial
sh ver | i System Bootstrap Version
08-29-2011 02:56 PM
If you use SecureCRT you can use VBScript. I could send you an example if you're interested.
04-12-2024 03:32 PM
I use SecureCRT. Can you share your scrpt?
Thank you,
08-29-2011 04:02 PM
Another option is perl. I use this script to get this info in one of the lab subnets via snmp. net-snmp needs to be installed on your system if you want to use it as is. May need to add another OID for uptime information.
#!/usr/bin/perl
system(clear);
open(STDERR , ">> /dev/null");
open(STDOUT , "> info_devices");
for ($int = 1; $int <= 124; $int = $int + 1) {
push(@IP , "192.168.23.$int ")
}
foreach $IP (@IP) {
print "\ninfo for $IP\n";
system("snmpget -v 2c -c public $IP SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysObjectID.0 SNMPv2-MIB::sysDescr.0");
}
- Dan
09-06-2011 03:06 PM
i do not have snmpget
my switches are on mutiple subnets
how do I do this per switch?
09-06-2011 05:27 PM
snmpget is part of the net-snmp package, it can be downloaded here: http://www.net-snmp.org/
#!/usr/bin/perl
system(clear);
open(STDERR , ">> /dev/null");
open(STDOUT , "> info_devices");
@IP = qw(10.34.1.3 192.168.3.2 10.55.94.1);
foreach $IP (@IP) {
print "\ninfo for $IP\n";
system("snmpget -v 2c -c public $IP SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysObjectID.0 SNMPv2-MIB::sysDescr.0");
}
09-06-2011 08:25 PM
Hi,
You can try Macro using teraterm, which is quite simple.... let me know if you have done with this if not will help you out...cheers...
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide