Home > Archive > PERL Miscellaneous > March 2005 > Cisco Perl Module & Cisco Connectivity
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Cisco Perl Module & Cisco Connectivity
|
|
| SallyBridges 2005-03-31, 3:58 pm |
| Hi,
I have been playing around as I want to be able to display some common
cisco commands as web pages so that we can let people view who is
connected without having to telnet on to the cisco equipment.
I have the following script that works for showing users connected but
i would like to show isdn active.
When i enter this in my box i only get a blank page, i am guessing as
there is a more statment and it may be expecting a response to dump to
screen ( only guessing )
Has any one got any ideas ( yeh it looks messy as cant install perl
modules where i want to either but its working / ish )
#!/usr/bin/perl -w
use lib'/home/httpd/html/test/';
use CGI;
use net::Telnet::Cisco;
$LOGIN = passw1;
$PASSWD = passw2;
$SESSION = Net::Telnet::Cisco->new(Host =>HOSTNAME);
$SESSION->login( $LOGIN, $PASSWD );
print "Content-type: text/plain\n\n";
# This is the command to show active users
$output =print $SESSION->cmd('sh user');
print $output
If you can help then many thanks ;)
| |
| A. Sinan Unur 2005-03-31, 3:58 pm |
| "SallyBridges" <sally.bridges@gmail.com> wrote in
news:1112274412.016243.37270@f14g2000cwb.googlegroups.com:
> When i enter this in my box i only get a blank page, i am guessing as
> there is a more statment and it may be expecting a response to dump to
> screen ( only guessing )
Why guess?
> Has any one got any ideas ( yeh it looks messy as cant install perl
> modules where i want to either but its working / ish )
>
> #!/usr/bin/perl -w
use warnings;
is preferable because it allows you to turn selected classes of warnings
on/off;
use strict;
> use lib'/home/httpd/html/test/';
> use CGI;
> use net::Telnet::Cisco;
Case matters.
use Net::Telnet::Cisco;
> $LOGIN = passw1;
> $PASSWD = passw2;
> $SESSION = Net::Telnet::Cisco->new(Host =>HOSTNAME);
> $SESSION->login( $LOGIN, $PASSWD );
> print "Content-type: text/plain\n\n";
Use facilities provided by the CGI module:
print header('text/plain');
> # This is the command to show active users
> $output =print $SESSION->cmd('sh user');
Do you know what print returns?
perldoc -f print
> print $output
Why would you want to output that?
> If you can help then many thanks ;)
I don't have a cisco router to test this, but the documentation for the
module you are using is very clear:
In your case, you can probably use (untested):
# !/usr/bin/perl
use strict;
use warnings;
$| = 1;
use lib'/home/httpd/html/test/';
use CGI;
use Net::Telnet::Cisco;
my $session = Net::Telnet::Cisco->new(Host => 'HOSTNAME');
print header('text/plain');
if($session->login('login', 'password')) {
print $session->cmd('sh user');
} else {
print "Error\n";
}
Please do read the posting guidelines for this group.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/c...guidelines.html
|
|
|
|
|