A Broadband and ADSL forum. BroadbanterBanter

Welcome to BroadbanterBanter.

You are currently viewing as a guest which gives you limited access to view most discussions and other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today.

Go Back   Home » BroadbanterBanter forum » Newsgroup Discussions » uk.telecom.broadband (UK broadband)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

uk.telecom.broadband (UK broadband) (uk.telecom.broadband) Discussion of broadband services, technology and equipment as provided in the UK. Discussions of specific services based on ADSL, cable modems or other broadband technology are also on-topic. Advertising is not allowed.

ActivePerl error message? Router script. Please help.Newbie



 
 
Thread Tools Display Modes
  #1  
Old May 17th 06, 02:58 PM posted to comp.lang.perl.misc,comp.lang.perl.modules,uk.telecom.broadband
[email protected]
external usenet poster
 
Posts: 16
Default ActivePerl error message? Router script. Please help.Newbie

Hi,

I have installed ActivePerl on Windows XP SP2 professional and have
tried running a script to restart my router: it always gives out this
message:

Can't locate Net/Telnet.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 5.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 5.

By default ActivePerl has installed Perl has been installed C:/Perl

I am running IIS.

The examples given in activeperl say that
"Note: the examples assume that PerlEx is installed on this machine,
and that the address http://localhost/PerlEx/scriptname is valid."

So I created a directory in c:\inetpub\wwwroot\ called perl and copied
and pasted all the files from C:/Perl into this directory in an attempt
to get this localhost to work. I have been running my script in
c:\inetpub\wwwroot\perl\
I've typed into Internet Explorer: http://localhost/perl/router.pl and
get the above error.

The script I have been trying to get to work is below:

I also tried turning on the starting the telnet service XP but this
didn't make any difference.
************************************************** *************

Here's some Perl that I've been playing with at home and at work
(being diverted from seeing some friends on Saturday morning to detour
into work to reboot the router provides an incentive to make sure the
ADSL line stays up). I run it from a cron job every 5 minutes.

Work: Vigor2600
Home: SpeedTouch 510

Both of them sometimes need a kick.

Notes: you will need to:
run the script as root if you use ICMP echo requests
change the IP addresses that it pings
change the username and password
change the command to reboot the system
do a bit of tidying up, especially if you are using Windows

Apologies to any Perl hackers out there for the coding style, from an
old fart who still thinks in Algol-60, -68, Fortran and C.

------8------8------8------8------8------8------8------8------8
#! /usr/bin/perl -w

use strict;

use Net::Telnet;
use Net::Ping;
use Sys::Syslog;
use Mail::Mailer;

# RFC1918 IP address of your router
my $localip = "192.168.0.254";

# a list of IP addresses to ping that are 1) few hops away, and 2)
# likely to be stable

# cheapest first
# next IP upstream 0.0.0.0 (from a traceroute)
# Your ISP's DNS servers: 0.0.0.1 & 0.0.0.2
# Your ISP's web server: 0.0.0.3
# i.root-servers.net: 192.36.148.17
# and any others you can think of

my @netips = ("0.0.0.0", "0.0.0.1", "0.0.0.2", "0.0.0.3",
"192.36.148.17" );
my $ip;
my $ok = 0;
my $mailer;

my $t; # telnet socket
my $p; # ping

my @lines;
my $i;
my $tmp;

$p = Net::Ping-new("icmp");

# log to syslog
openlog( "routerping", "", "user" );

foreach $ip (@netips)
{
if ( $p-ping($ip) )
{
$ok = 1;
last;
}
else
{
syslog( 'debug', "can't ping %s", $ip );
}
}

if ( ! $ok )
{
syslog( 'debug', "%s", "rebooting router" );

# make sure that there is a route to the ADSL router's local
# IP address
system( "ip route add " . $localip . "/32 dev eth1" );

$t = Net::Telnet-new( Timeout = 10, Prompt = '/ /', Host =
$localip );

$t-input_log( "/var/log/router.log" );

# if your router asks for a username and password, use this:
$t-login("Administrator", "zxc314" ) or die "login failed";

# else if it just prompts for a password use this:

$t-waitfor("/Password:/" ) or die "login waitfor 1 failed";
$t-print("fr0gR0utr" ) or die "login print failed";
$t-waitfor("/ /" ) or die "login waitfor 2 failed";

@lines = $t-cmd("adsl status");
# or perhaps
@lines = $t-cmd("adsl info");

$t-print("system reboot");
# or perhaps
$t-print("sys reboot");

$t-close;

$mailer = Mail::Mailer-new("smtp", Server = "localhost") || die
"can't new mail";

$mailer-open({ From = 'root',
To = 'root',
Subject= "router reboot",
}) or die "can't open mail";

print $mailer "router reboot";

$mailer-close() || die "can't close mail";
}
------8------8------8------8------8------8------8------8------8

  #3  
Old May 17th 06, 04:20 PM posted to comp.lang.perl.misc,comp.lang.perl.modules,uk.telecom.broadband
[email protected]
external usenet poster
 
Posts: 16
Default ActivePerl error message? Router script. Please help.Newbie

Hi,

Thanks Oliver for your help.

I have added all the .pm files from CPAN in the appropriate directories

Telnet.pm
Mailer.pm
Syslog.pm
template.pm

Please could you explain this error message:

Undefined subroutine &main:penlog called at
c:\inetpub\wwwroot\perl\router.pl line 38.

Thankyou.

Line 38 says:

openlog( "routerping", "", "user" );

  #8  
Old May 18th 06, 11:22 AM posted to comp.lang.perl.misc,comp.lang.perl.modules,uk.telecom.broadband
[email protected]
external usenet poster
 
Posts: 16
Default ActivePerl error message? Router script. Please help.Newbie

Hi,

Thanks for all your help. I installed
Telnet.pm
Mailer.pm
Syslog.pm
template.pm manually because I couldn't work out how to get ppm to do anything. Now I've got it ppm working.

So now I've:
1 uninstalled ActivePerl
2 Restarted WinXP Pro
3 deleted c:\Perl to remove any of my previous manually installed .pm
files.
4 Reinstalled ActivePerl
5 Tried running the Perl script mentioned in the first post in this
thread.
6 Of course got the same error message as 1st mentioned:
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 5.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 5.
7 Did C: ppm install Net-Telnet
8 Ran Perl Script as mentioned in the first post.
9 Get error:
Can't locate Sys/Syslog.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 7.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 7.
10 Did c:ppm search sys-syslog
Searching in Active Repositories
No matches for 'sys-syslog'; see 'help search'.

Does this mean as Charles DeRykus says that there is no Win32 port of
Sys-syslog?

Is there anyway of getting this script to work in windows?

When I run:
#!/usr/bin/perl
use warnings;
use strict;
use Sys::Syslog;
openlog("","","user");
__END__
I get the same error message:

Can't locate Sys/Syslog.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\olivertest2.pl line 4.
BEGIN failed--compilation aborted at
c:\inetpub\wwwroot\perl\olivertest2.pl line 4.

What does line 42 say?

if ( $p-ping($ip) )

Thanks. Are there any similar scripts out there that may do the same
thing that would work in Windows. Thanks.

  #9  
Old May 18th 06, 11:53 AM posted to comp.lang.perl.misc,comp.lang.perl.modules,uk.telecom.broadband
Nick
external usenet poster
 
Posts: 28
Default ActivePerl error message? Router script. Please help.Newbie

wrote:
Hi,

Thanks for all your help. I installed

Telnet.pm
Mailer.pm
Syslog.pm
template.pm manually because I couldn't work out how to get ppm to do anything. Now I've got it ppm working.


So now I've:
1 uninstalled ActivePerl
2 Restarted WinXP Pro
3 deleted c:\Perl to remove any of my previous manually installed .pm
files.
4 Reinstalled ActivePerl
5 Tried running the Perl script mentioned in the first post in this
thread.
6 Of course got the same error message as 1st mentioned:
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 5.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 5.
7 Did C: ppm install Net-Telnet
8 Ran Perl Script as mentioned in the first post.
9 Get error:
Can't locate Sys/Syslog.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 7.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 7.
10 Did c:ppm search sys-syslog
Searching in Active Repositories
No matches for 'sys-syslog'; see 'help search'.

Does this mean as Charles DeRykus says that there is no Win32 port of
Sys-syslog?

Is there anyway of getting this script to work in windows?

When I run:
#!/usr/bin/perl
use warnings;
use strict;
use Sys::Syslog;
openlog("","","user");
__END__
I get the same error message:

Can't locate Sys/Syslog.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\olivertest2.pl line 4.
BEGIN failed--compilation aborted at
c:\inetpub\wwwroot\perl\olivertest2.pl line 4.


What does line 42 say?


if ( $p-ping($ip) )

Thanks. Are there any similar scripts out there that may do the same
thing that would work in Windows. Thanks.


If you don't really need the logging capabilities, you could always just
comment out line 32...?

xF,

....Nick
  #10  
Old May 18th 06, 11:54 AM posted to comp.lang.perl.misc,comp.lang.perl.modules,uk.telecom.broadband
Nick
external usenet poster
 
Posts: 28
Default ActivePerl error message? Router script. Please help.Newbie

[...]line 32...[...]

By which, of course, I meant "38"!
 




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What does this message from my router mean - if anything? [email protected] uk.comp.home-networking (UK home networking) 3 December 21st 05 11:34 AM
USB Drivers -- A curious error message. David G. Bell uk.telecom.broadband (UK broadband) 5 July 9th 05 12:00 AM
ANYONE have a `TUT SYSTEMS` MXL 2300` Router...I Need the drivers.. Seriel number, been peeled/scratched off_& needed it to get drivers of web site__see message inside..TIA .####[][][][]####[][][][]####[][][][]####[][][][]####[][][][]####[][][]][ [ P.B.S] uk.telecom.broadband (UK broadband) 1 February 6th 05 08:19 AM
Error message Motorcyclesaur uk.comp.home-networking (UK home networking) 12 February 25th 04 08:48 PM


All times are GMT +1. The time now is 10:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.Content Relevant URLs by vBSEO 2.4.0
Copyright 2004-2019 BroadbanterBanter.
The comments are property of their posters.