- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Looking for assistance in getting this script work...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 02:26 AM
тАО02-07-2005 02:26 AM
I got this script a few years back and used it to change telnet/enable passwords, SNMP community strings and a few other things. I'm trying to get it working at another site but 'am having problems. Here's the error message I'm getting and the script.
***********************************************
$ ./rcisco_dc.scr
socket: Protocol not supported at ./rcisco_dc.scr line 106.
$ cat rcisco_dc.scr
#!/usr/bin/perl
#
# $Header: /home/aggarwal/lsrc/nocol/src/perlnocol/RCS/rcisco,v 1.3 1993/10/17 11:55:33 aggarwal Exp $
#
# rcisco - perl routine to execute a Cisco router command remotely
#
# Programmer: Christopher Sedore
# Revised by: John Wobus, jmwobus@mailbox.syr.edu
#
# (c) Syracuse University Computing & Network Services 1993
#
# No warranty is expressed or implied. Permission to copy and use is
# extended to all. Permission to redistribute is granted under the
# following conditions: it is not sold for profit; this copyright
# notice remains intact; the same permissions extend to the recipient;
# and if any changes are made, a notice is added so stating.
#
# Command Format:
#
# rcisco_mod
#
# Signs on to Cisco router, executes command, and returns the
# result.
#
#
#
#
#
#
#
#
# Example Call:
#
# rcisco mycisco.excellent.edu "show hardware"
#
# This command signs on to myscisco.excellent.edu, executes the
# command "show hardware" and sends the result to the standard
# output.
#
# Depends upon:
# hostname - Unix command to list a host's name.
#
# To install this:
# (1) Assign the perl variables below appropriately.
# (2) Put this file whereever you want.
#
########################################################
#
#
# The command format is now:
#
# rcisco_wrnet.scr
#
#
require "ctime.pl";
#
$defaultrouter="10.21.21.14"; # Default router.
$defaultpasswd="ciscoworks"; # PW of the router.
$default_en_passwd="ciscoworks password"; # PW of the router.
$defaultcommand="show version"; # Command to exec on router
$defaultport=23; # Default TCP port.
#
# main routine
#
($them,$passwd,$en_passwd,$command,$command1,$port) = @ARGV;
$them = $defaultrouter unless $them;
$passwd = $defaultpasswd unless $passwd;
$en_passwd = $default_en_passwd unless $en_passwd;
$command = $defaultcommand unless $command;
$port = $defaultport unless $port; # usually should be port 23
$date = &ctime(time);
$AF_INET = 2;
$SOCK_STREAM = 1;
$SIG{'INT'} = 'dokill';
sub dokill { kill 9,$child if $child; }
# require "$socketph";
$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
if ($them =~ /^\d+/) # IP address specified
{
local(@a) = split (/\./,$them);
$thataddr = pack ('C4', @a);
}
else {
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
}
$thataddr || die "Unknown host: $!";
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die $date,"connect: $!";
select(S); $| = 1; select(STDOUT); # set socket to be command buffered
if ($child = fork) {
print S "$passwd\n";
print S "terminal length 0\n"; # dont need a 'more'
sleep 3; #some routers work better with this.
print S "en\n"; # tac modified
sleep 3; # tac modified
print S "$en_passwd\n"; # tac modified
sleep 3;
print S "sh ver\n"; # start config mode
sleep 3;
# print S "line vty 0 4\n"; # enter line mode
# sleep 3;
# print S "password short\n"; # set base level password
# sleep 3;
# print S "exit\n"; # exit line mode
# sleep 3;
# print S "enable secret stop\n"; # set enable level password
# sleep 3;
# print S "exit \n"; # exit from enable mode
# print S "wr mem \n"; # write changes to router memory
# sleep 5;
print S "quit\n";
sleep 3;
do dokill();
}
else {
while (
}
$
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 02:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 02:36 AM
тАО02-07-2005 02:36 AM
Re: Looking for assistance in getting this script working...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 03:45 AM
тАО02-07-2005 03:45 AM
Re: Looking for assistance in getting this script working...
Here's the issue I'm facing now though. When I used the script before, the Cisco devices weren't setup to use TACACs. Where I'm at now, they're using TACACs. The only difference is this; when telneting to the device you are prompted for a Username: - not just a Password:. I tried adding a variable for defaultuser but it's not working. What am I doing wrong? Again, I'm not a scripter...
*********************************************
$ cat rcisco_dc.scr
#!/usr/bin/perl
#
# $Header: /home/aggarwal/lsrc/nocol/src/perlnocol/RCS/rcisco,v 1.3 1993/10/17 11:55:33 aggarwal Exp $
#
# rcisco - perl routine to execute a Cisco router command remotely
#
# Programmer: Christopher Sedore
# Revised by: John Wobus, jmwobus@mailbox.syr.edu
#
# (c) Syracuse University Computing & Network Services 1993
#
# No warranty is expressed or implied. Permission to copy and use is
# extended to all. Permission to redistribute is granted under the
# following conditions: it is not sold for profit; this copyright
# notice remains intact; the same permissions extend to the recipient;
# and if any changes are made, a notice is added so stating.
#
# Command Format:
#
# rcisco_mod
#
# Signs on to Cisco router, executes command, and returns the
# result.
#
#
#
#
#
#
#
#
# Example Call:
#
# rcisco mycisco.excellent.edu "show hardware"
#
# This command signs on to myscisco.excellent.edu, executes the
# command "show hardware" and sends the result to the standard
# output.
#
# Depends upon:
# hostname - Unix command to list a host's name.
#
# To install this:
# (1) Assign the perl variables below appropriately.
# (2) Put this file whereever you want.
#
########################################################
#
#
# The command format is now:
#
# rcisco_wrnet.scr
#
#
require "ctime.pl";
#
$defaultrouter="10.21.21.14"; # Default router.
$defaultuser="ciscoworks"; # UserID of the router.
$defaultpasswd="password for CW"; # PW for the router.
$default_en_passwd="en pwd for CW"; # Enable PW for the router.
$defaultcommand="show version"; # Command to exec on router
$defaultport=23; # Default TCP port.
#
# main routine
#
#($them,$passwd,$en_passwd,$command,$command1,$port) = @ARGV;
($them,$user,$passwd,$en_passwd,$command,$command1,$port) = @ARGV;
$them = $defaultrouter unless $them;
$defaultuser = $defaultuser unless $passwd;
$passwd = $defaultpasswd unless $passwd;
$en_passwd = $default_en_passwd unless $en_passwd;
$command = $defaultcommand unless $command;
$port = $defaultport unless $port; # usually should be port 23
$date = &ctime(time);
$AF_INET = 2;
$SOCK_STREAM = 2;
$SIG{'INT'} = 'dokill';
sub dokill { kill 9,$child if $child; }
# require "$socketph";
$sockaddr = 'S n a4 x8';
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
if ($them =~ /^\d+/) # IP address specified
{
local(@a) = split (/\./,$them);
$thataddr = pack ('C4', @a);
}
else {
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
}
$thataddr || die "Unknown host: $!";
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die $date,"connect: $!";
select(S); $| = 1; select(STDOUT); # set socket to be command buffered
if ($child = fork) {
print S "$passwd\n";
print S "terminal length 0\n"; # dont need a 'more'
sleep 3; #some routers work better with this.
print S "en\n"; # tac modified
sleep 3; # tac modified
print S "$en_passwd\n"; # tac modified
sleep 3;
print S "sh ver\n"; # start config mode
sleep 3;
# print S "line vty 0 4\n"; # enter line mode
# sleep 3;
# print S "password short\n"; # set base level password
# sleep 3;
# print S "exit\n"; # exit line mode
# sleep 3;
# print S "enable secret stop\n"; # set enable level password
# sleep 3;
# print S "exit \n"; # exit from enable mode
# print S "wr mem \n"; # write changes to router memory
# sleep 5;
print S "quit\n";
sleep 3;
do dokill();
}
else {
while (
}
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 03:51 AM
тАО02-07-2005 03:51 AM
Re: Looking for assistance in getting this script working...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-07-2005 04:01 AM
тАО02-07-2005 04:01 AM
Re: Looking for assistance in getting this script working...
Thanks for your help on this. Even though your second response fixed the script, I only submitted 7 points because I thought I would need more help but I was able to get it working. What I did was submit more points to your first response.
Again, Thank you so much.