Networking Forums

Networking Forums > Computer Networking > Broadband > ActivePerl error message? Router script. Please help.Newbie

Reply
Thread Tools Display Modes

ActivePerl error message? Router script. Please help.Newbie

 
 
wrreisen2@yahoo.com
Guest
Posts: n/a

 
      05-17-2006, 01:58 PM
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<

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a

 
      05-17-2006, 02:14 PM
In comp.lang.perl.misc (E-Mail Removed) wrote:
: Hi,

: 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.

This message says it all: Can't locate Net/Telnet.pm at line 5.

[...lots of stuff snipped here...]

: use Net::Telnet; # And this is line 5 of your code.

[...code snipped...]

By default, ActiveState's Perl installation doesn't contain the Net::
Telnet module, only Net::HTTP is there. You just have to install Net::
Telnet from CPAN, ideally via ActivePerl's install manager.

The other measures you described in your mail are not necessary; if
ActiveState Perl is allowed to install properly, then it will any .pl
script anywhere will start up.

Oliver.


--
Dr. Oliver Corff e-mail: (E-Mail Removed)
 
Reply With Quote
 
wrreisen2@yahoo.com
Guest
Posts: n/a

 
      05-17-2006, 03:20 PM
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" );

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a

 
      05-17-2006, 03:54 PM
(E-Mail Removed) wrote in news:1147879258.999380.225030
@j73g2000cwa.googlegroups.com:

> I have added all the .pm files from CPAN in the appropriate directories
>
> Telnet.pm
> Mailer.pm
> Syslog.pm
> template.pm


With your lack of experience and expertise, how do you know you installed
them in the correct directories?

Please use ppm which is distributed with AS Perl to find and install
packages.

> Please could you explain this error message:


Please, could you read the posting guidelines and follow them to help us
help you?

While you are at it, please also quote properly when replying.

> Undefined subroutine &main:penlog called at
> c:\inetpub\wwwroot\perl\router.pl line 38.
>
> Thankyou.
>
> Line 38 says:
>
> openlog( "routerping", "", "user" );


What does line 42 say?

Sinan
 
Reply With Quote
 
Guest
Posts: n/a

 
      05-17-2006, 04:11 PM
In comp.lang.perl.misc (E-Mail Removed) wrote:
: Hi,

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

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

Did you install manually or let the package makefile do the work?

: Please could you explain this error message:

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

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

No, I can't. The following complete minimal example does not produce
any error message on my system:

#!/usr/bin/perl
use warnings;
use strict;
use Sys::Syslog;
openlog("","","user");
__END__

Can you try this and verify?

Oliver.

--
Dr. Oliver Corff e-mail: (E-Mail Removed)
 
Reply With Quote
 
Charles DeRykus
Guest
Posts: n/a

 
      05-17-2006, 05:51 PM
(E-Mail Removed) wrote:
> 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" );
>


Just a guess but `openlog` may be a Sys::Syslog method... (I thought
Sys::Syslog was Unix only too but maybe there's been some kind of Win32
port).

--
Charles DeRykus
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a

 
      05-17-2006, 09:15 PM
(E-Mail Removed) wrote:

> 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


why didn't you do:

C:> ppm install Net-Telnet

?

Note that if you have set up your Win XP Pro properly, you have to run the
command prompt as Administrator (or a user with admin rights) in order to
be able to execute ppm. If it works out of the box, you probably should
rethink your account rights.

--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
 
Reply With Quote
 
wrreisen2@yahoo.com
Guest
Posts: n/a

 
      05-18-2006, 10:22 AM
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.

 
Reply With Quote
 
Nick
Guest
Posts: n/a

 
      05-18-2006, 10:53 AM
(E-Mail Removed) 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
 
Reply With Quote
 
Nick
Guest
Posts: n/a

 
      05-18-2006, 10:54 AM
[...]line 32...[...]

By which, of course, I meant "38"!
 
Reply With Quote
 
 
 
Reply

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BT router error message David Broadband 2 11-17-2009 01:36 PM
Why is pktgen v1.3 causing an error message like this? (See message body) gregg.drwho8@gmail.com Linux Networking 0 12-29-2006 03:43 AM
Error message during CD installation for Linksys wireless router azik Wireless Networks 0 07-16-2006 03:04 PM
Still getting Internet Explorer error message before Barricade router completes dial-up connection Karl Loucks Windows Networking 1 12-24-2003 01:39 PM
Internet Explorer error message before Barricade router completes dial-up connection Karl Loucks Windows Networking 3 10-08-2003 06:05 AM



1 2 3 4 5 6 7 8 9 10 11