Sponsored Content
Top Forums Shell Programming and Scripting Perl variables inside Net::Telnet::Cisco Module doesn't work Post 302482597 by ahmed_zaher on Wednesday 22nd of December 2010 04:12:08 AM
Old 12-22-2010
Hello,

Thanks for your reply, it work fine but I have another problem.

this the whole script:
Code:
use Net::Telnet::Cisco;
$device = "10.14.199.1";
($o1, $o2, $o3, $o4) = split(/\./,$device);
print "$o1\n";
print "$o2\n";
print "$o3\n";
print "$o4\n";
my $session = Net::Telnet::Cisco->new(Host => "$device");
$session->login("cisco", "cisco");
$session->cmd("conf t");
@output = $session->cmd("ip dhcp excluded-address 172.18.$o3.1 172.18.$o3.20");
print "@output\n";
@output = $session->cmd("ip dhcp excluded-address 10.14.$o3.130 10.14.$o3.145");
print "@output\n";
@output = $session->cmd("ip dhcp excluded-address 10.14.$o3.230 10.14.$o3.254");
print "@output\n";
@output = $session->cmd("ip dhcp pool Users-pool");
print "@output\n";
@output = $session->cmd("network 10.14.$o3.128 255.255.255.128");
print "@output\n";
@output = $session->cmd("default-router 10.14.$o3.129");
print "@output\n";
@output = $session->cmd("dns-server 10.11.0.80 10.11.0.81 10.11.0.79 192.168.250.250 192.168.250.251");
print "@output\n";
@output = $session->cmd("ip dhcp pool Remedy-pool");
print "@output\n";
@output = $session->cmd("network 10.15.$o3.0 255.255.255.0");
print "@output\n";
@output = $session->cmd("default-router 10.15.$o3.1");
print "@output\n";
@output = $session->cmd("dns-server 10.11.0.80 10.11.0.81 10.11.0.79 192.168.250.250 192.168.250.251");
print "@output\n";
@output = $session->cmd("ip dhcp pool Voice");
print "@output\n";
@output = $session->cmd("network 172.18.$o3.0 255.255.255.0");
print "@output\n";
@output = $session->cmd("default-router 172.18.$o3.1");
print "@output\n";
@output = $session->cmd("option 150 ip 172.17.40.10");
print "@output\n";
$session->close;


but I have the following error:
Code:
C:\Users\Administrator>perl c:\Scripts\dhcp.pl
Can't locate auto/Net/Telnet/Cisco/autosplit.ix in @INC (@INC contains: F:/Perl/
site/lib F:/Perl/lib .) at F:/Perl/lib/AutoLoader.pm line 173.
 at F:/Perl/lib/Net/Telnet/Cisco.pm line 18
10
14
199
1
 
command timed-out at c:\Scripts\dhcp.pl line 17

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies

2. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

3. Windows & DOS: Issues & Discussions

Need Help on "waitfor" command in net::Telnet Module in PERL

Hi, Can anybody help me in writing command "waitfor" for string "C:\WINNT\Profiles\mfcf0508>" while using net::Telnet module. I tried the below format : $telnet->waitfor('/"C\:\WINNT\Profiles\mfcf0508>".*$/i'); Getting error as : pattern match timed-out Plz help me (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

4. Shell Programming and Scripting

Need help on use of "cmd" command in net::Telnet module in PERL

in "cmd" command i want to copy the ouput of the command excuted to a particular file in a directory. How to do this..?? Ex : $telnet->cmd(String => 'allip:acl=a1;',Prompt => '/</'); i want to copy o/p of the command "allip:acl=a1;" in a log file in a particular directory. Plz suggest.. (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

5. Shell Programming and Scripting

cd command doesn't work through variables

Hi.... cd command is not working when dual string drive/volume name is passed to cd through variables....... For Ex.... y=/Volumes/Backup\ vipin/ cd $y the above command gives error....... anyone with a genuine solution ? (16 Replies)
Discussion started by: vipinchauhan222
16 Replies

6. Shell Programming and Scripting

perl telnet issue with cisco

Hi Experts, I am using perl to telnet on cisco boxes. We have this stupid cisco node which does not support "terminal Length0" command. Since I am using Net::Telnet and capturing output with @output = $telnet->cmd('cmd'); Say @output = $telnet->cmd('show version'); Now problem... (2 Replies)
Discussion started by: mtomar
2 Replies

7. Shell Programming and Scripting

perl Net::SNMP version getting info from cisco switch

I am having trouble working with SNMP module with perl. I am trying to get SNMP version of target system. I use following code to get it however it resturns error as "Argument "v6.0.1" isn't numeric in numeric lt (<) at ./chk_env_upd.pl line 447." Get load table my $resultat =... (1 Reply)
Discussion started by: dynamax
1 Replies

8. Shell Programming and Scripting

Perl Telnet cisco routers

Hi all i have little problem finding solution about simple telnet script .... i have 250 routers and on some i have different password and on some they ask just for password no username. So for example 1,2,3 have username and password (user,password) 4, and 5 have different username and password... (0 Replies)
Discussion started by: IvanMP
0 Replies

9. Shell Programming and Scripting

Switching user inside a shell script doesn't seem to work

Linux version : Oracle Linux 6.4 Shell : Bash The following script will be run as root. During the execution, it should switch to oracle user and execute few commands. After googling and searching within unix.com , I came up with the following syntax ## Enclosing all commands in double... (7 Replies)
Discussion started by: John K
7 Replies

10. AIX

PING to AIX works but TELNET FTP SSH doesn't work

root@PRD /> rsh DR KFAFH_DR: protocol failure due to unexpected closure from server end root@PRD /> telnet DR Trying... Connected to DR. Escape character is '^]'. Connection closed. root@PRD /> ftp DR Connected to KFAFH_DR. 421 Service not available, remote server has closed connection... (2 Replies)
Discussion started by: filosophizer
2 Replies
UNIVERSAL::require(3)					User Contributed Perl Documentation				     UNIVERSAL::require(3)

NAME
UNIVERSAL::require - require() modules from a variable SYNOPSIS
# This only needs to be said once in your program. require UNIVERSAL::require; # Same as "require Some::Module" my $module = 'Some::Module'; $module->require or die $@; # Same as "use Some::Module" BEGIN { $module->use or die $@ } DESCRIPTION
If you've ever had to do this... eval "require $module"; to get around the bareword caveats on require(), this module is for you. It creates a universal require() class method that will work with every Perl module and its secure. So instead of doing some arcane eval() work, you can do this: $module->require; It doesn't save you much typing, but it'll make alot more sense to someone who's not a ninth level Perl acolyte. Methods require my $return_val = $module->require or die $@; my $return_val = $module->require($version) or die $@; This works exactly like Perl's require, except without the bareword restriction, and it doesn't die. Since require() is placed in the UNIVERSAL namespace, it will work on any module. You just have to use UNIVERSAL::require somewhere in your code. Should the module require fail, or not be a high enough $version, it will simply return false and not die. The error will be in $@ as well as $UNIVERSAL::require::ERROR. $module->require or die $@; use my $require_return = $module->use or die $@; my $require_return = $module->use(@imports) or die $@; Like "UNIVERSAL::require", this allows you to "use" a $module without having to eval to work around the bareword requirement. It returns the same as require. Should either the require or the import fail it will return false. The error will be in $@. If possible, call this inside a BEGIN block to emulate a normal "use" as closely as possible. BEGIN { $module->use } SECURITY NOTES
UNIVERSAL::require makes use of "eval STRING". In previous versions of UNIVERSAL::require it was discovered that one could craft a class name which would result in code being executed. This hole has been closed. The only variables now exposed to "eval STRING" are the caller's package, filename and line which are not tainted. UNIVERSAL::require is taint clean. COPYRIGHT
Copyright 2001, 2005 by Michael G Schwern <schwern@pobox.com>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html AUTHOR
Michael G Schwern <schwern@pobox.com> SEE ALSO
Module::Load, "require" in perlfunc, <http://dev.perl.org/rfc/253.pod> perl v5.16.2 2009-03-30 UNIVERSAL::require(3)
All times are GMT -4. The time now is 05:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy