Ask a Question related to PERL Modules, Design and Development.
-
wrreisen2@yahoo.com #1
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 [url]http://localhost/PerlEx/scriptname[/url] 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: [url]http://localhost/perl/router.pl[/url] 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<
wrreisen2@yahoo.com Guest
-
Newbie question re error message
Hi all I have installed MySQL 4.0.25 (and PHP 4.4.2.2) on my Windows XP Pro system using IISadmin. PHP is working OK but MySQL shows the MySQL... -
total newbie re compilation error message
:confused; trying an altered version of the small sample program in Flex, but I get the error message "Error /firstapp.mxml:3 The markup in the... -
wse router --encrypting the message thru policies
Hi Everyone Wen i encrypt he message(using policies ) send through the router , the message doesnt encrypt . When i do with code the data is... -
a script stop without any error message
Hi All, I have a php script. It checks more 10k phone numbers, for each of the numbers it will send the it to a remote host for validation and... -
newbie Variable script error - Help!
I've been using Director for nice linear keyframed animations for years -- thanks, MM! Now I would like to speed things up using Lingo (replacing... -
Re: ActivePerl error message? Router script. Please help.Newbie
In comp.lang.perl.misc [email]wrreisen2@yahoo.com[/email] 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: [email]corff@zedat.fu-berlin.de[/email]
Guest
-
wrreisen2@yahoo.com #3
Re: 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::openlog called at
c:\inetpub\wwwroot\perl\router.pl line 38.
Thankyou.
Line 38 says:
openlog( "routerping", "", "user" );
wrreisen2@yahoo.com Guest
-
A. Sinan Unur #4
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote in news:1147879258.999380.225030
@j73g2000cwa.googlegroups.com:
With your lack of experience and expertise, how do you know you installed> I have added all the .pm files from CPAN in the appropriate directories
>
> Telnet.pm
> Mailer.pm
> Syslog.pm
> template.pm
them in the correct directories?
Please use ppm which is distributed with AS Perl to find and install
packages.
Please, could you read the posting guidelines and follow them to help us> Please could you explain this error message:
help you?
While you are at it, please also quote properly when replying.
What does line 42 say?> Undefined subroutine &main::openlog called at
> c:\inetpub\wwwroot\perl\router.pl line 38.
>
> Thankyou.
>
> Line 38 says:
>
> openlog( "routerping", "", "user" );
Sinan
A. Sinan Unur Guest
-
Re: ActivePerl error message? Router script. Please help.Newbie
In comp.lang.perl.misc [email]wrreisen2@yahoo.com[/email] 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::openlog 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: [email]corff@zedat.fu-berlin.de[/email]
Guest
-
Charles DeRykus #6
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
Just a guess but `openlog` may be a Sys::Syslog method... (I thought> 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::openlog called at
> c:\inetpub\wwwroot\perl\router.pl line 38.
>
> Thankyou.
>
> Line 38 says:
>
> openlog( "routerping", "", "user" );
>
Sys::Syslog was Unix only too but maybe there's been some kind of Win32
port).
--
Charles DeRykus
Charles DeRykus Guest
-
John Bokma #7
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
why didn't you do:> 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
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: [url]http://castleamber.com/[/url]
John Bokma Guest
-
wrreisen2@yahoo.com #8
Re: ActivePerl error message? Router script. Please help.Newbie
Hi,
Thanks for all your help. I installedSo now I've:> 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.
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.
if ( $p->ping($ip) )>What does line 42 say?
Thanks. Are there any similar scripts out there that may do the same
thing that would work in Windows. Thanks.
wrreisen2@yahoo.com Guest
-
Nick #9
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
If you don't really need the logging capabilities, you could always just> 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.
>
comment out line 32...?
xF,
....Nick
Nick Guest
-
Nick #10
Re: ActivePerl error message? Router script. Please help.Newbie
[...]line 32...[...]
By which, of course, I meant "38"!
Nick Guest
-
wrreisen2@yahoo.com #11
Re: ActivePerl error message? Router script. Please help.Newbie
Thanks Nick
Have commented out line 7
# use Sys::Syslog;
and line 38
When I run the script it now gives:
Can't locate Mail/Mailer.pm in @INC (@INC contains: C:/Perl/lib
C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 8.
BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
line 8.
I did c:>ppm search mail-mailer
There isn't one. I presume that this means that mail-mailer isn't
available for Win32?
I would guess it wouldn't work if I commented out the lines to do with
this Mail-mailer module?
$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";
}
Is there some other way? Thanks again.
wrreisen2@yahoo.com Guest
-
wrreisen2@yahoo.com #12
Re: ActivePerl error message? Router script. Please help.Newbie
The solution might be to run an Linux emulator on XP and run it on that
I suppose?
wrreisen2@yahoo.com Guest
-
Nicholas Thomas #13
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
Just comment out all the mailer stuff as well. It's for notification, so> Thanks Nick
>
> Have commented out line 7
> # use Sys::Syslog;
> and line 38
>
> When I run the script it now gives:
> Can't locate Mail/Mailer.pm in @INC (@INC contains: C:/Perl/lib
> C:/Perl/site/lib .) at c:\inetpub\wwwroot\perl\router.pl line 8.
> BEGIN failed--compilation aborted at c:\inetpub\wwwroot\perl\router.pl
> line 8.
> I did c:>ppm search mail-mailer
> There isn't one. I presume that this means that mail-mailer isn't
> available for Win32?
> I would guess it wouldn't work if I commented out the lines to do with
> this Mail-mailer module?
>
> $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";
> }
>
> Is there some other way? Thanks again.
>
- unless you need it for some particular reason - you can get rid of it.
If you do want logging capabilities, then it's a simple enough matter to
just write directly to a file, somewhere. A quick read-up on Perl will
tell you how :)
xF,
....Nick
Nicholas Thomas Guest
-
l v #14
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
If you are only going to run on windows, you can log in the windows> 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.
>
event log by using Win32::EventLog.
--
Len
l v Guest
-
wrreisen2@yahoo.com #15
Re: ActivePerl error message? Router script. Please help.Newbie
Thanks Nick & Len,
I have commented out all to do with the Mailer and Syslog now. I get
the error message:
CGI Error
The specified CGI application misbehaved by not returning a complete
set of HTTP headers. The headers it did return are:
'ip' is not recognized as an internal or external command,
operable program or batch file.
problem connecting to "192.168.0.254", port 23: Unknown error at
c:\inetpub\wwwroot\perl\router_be.pl line 61
192.168.0.254 is the IP of my router on my network. Why have a go on
port 23?
[url]http://www.edimax.nl/download/manual/AR-7024_M.zip[/url] is the manual for
this router. Is there something I should configure to do with ports on
this?
There is this from the manual? Would these be relevant:
HTTP Server Port: This field allows the user to specify the port of the
Web access. . For example, when it is changed to 1001, the HTTP server
address for the LAN side is [url]http://10.0.0.2:1001[/url]
And:
3.3.9 Configuration - Virtual Server Configuration
The Virtual Server Configuration page allows the user to set the
configuration of Virtual Server. The Conexant firmware includes the
Free BSD version firewall. All UDP/TCP ports are protected from
intrusion. If any specific local PCs need to be mapped to the UDP/TCP
port on WAN side, please input the mappings here.
Public Port: This field allows the user to enter the port number of the
Public Network.
Private Port: This field allows the user to enter the port number of
the Private Network.In most cases, the private port number is same as
public port number.
Host IP Address: This field allows the user to enter the private
network IP address for the particular sever.
Thanks again.
wrreisen2@yahoo.com Guest
-
wrreisen2@yahoo.com #16
Re: ActivePerl error message? Router script. Please help.Newbie
Sorry forgot. This is the code now. Thanks.
#! /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";
}
wrreisen2@yahoo.com Guest
-
l v #17
Re: ActivePerl error message? Router script. Please help.Newbie
[email]wrreisen2@yahoo.com[/email] wrote:
You need to return valid HTTP headers back to your browser in order to> Thanks Nick & Len,
>
> I have commented out all to do with the Mailer and Syslog now. I get
> the error message:
>
> CGI Error
> The specified CGI application misbehaved by not returning a complete
> set of HTTP headers. The headers it did return are:
tell it what to do.
print "Content-type: text/html\n\n";
from your code in the other post you tell your pc/server to run the>
> 'ip' is not recognized as an internal or external command,
> operable program or batch file.
> problem connecting to "192.168.0.254", port 23: Unknown error at
> c:\inetpub\wwwroot\perl\router_be.pl line 61
command ip route add ... . I'm guessing that the command is invalid and
should be route add ... or are you trying to run that command remotely
on your ADSL router?> system( "ip route add " . $localip . "/32 dev eth1" );Telnet uses port 23.>
> 192.168.0.254 is the IP of my router on my network. Why have a go on
> port 23?[snip]>
> [url]http://www.edimax.nl/download/manual/AR-7024_M.zip[/url] is the manual for
> this router. Is there something I should configure to do with ports on
> this?
>> Thanks again.
>
--
Len
l v Guest
-
Alan J. Wylie #18
Re: ActivePerl error message? Router script. Please help.Newbie
Firstly, as the original author of this code, my apologies to the perl
groups for the inconvenience.
The original posting was accompanied by the text:
| 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.
On 18 May 2006 08:52:12 -0700, [email]wrreisen2@yahoo.com[/email] said:
> I have commented out all to do with the Mailer and Syslog now. I get
> the error message:How on earth are you getting those errors? This script has nothing to> CGI Error The specified CGI application misbehaved by not returning
> a complete set of HTTP headers. The headers it did return are:
do with the web, browsers or HTTP. Run the script from a command line.
> 'ip' is not recognized as an internal or external command, operable
> program or batch file. problem connecting to "192.168.0.254", port
> 23: Unknown error at c:\inetpub\wwwroot\perl\router_be.pl line 61> 192.168.0.254 is the IP of my router on my network. Why have a go on
> port 23?<snippage>> Sorry forgot. This is the code now. Thanks.
Telnet is a ancient protocol used as a command line interface> use Net::Telnet;
to remote computers. It runs on port 23.
Windows has (or did last time I looked) a telnet application. You can
probably invoke it with something like Windows Menu->Run Command and
enter telnet in the box. Supply the IP address of your router, and see
if you get a response. Then see what commands it accepts. "help" or "?"
(without the quotes) are often useful.
That's the same as my IP router's IP address. Coincidence? Or do you need to> my $localip = "192.168.0.254";
change it?
> # a list of IP addresses to ping that are 1) few hops away, and 2)
> # likely to be stableMost of those IP addresses are clearly invalid, and as I originally said,> my @netips = ("0.0.0.0", "0.0.0.1", "0.0.0.2", "0.0.0.3",
> "192.36.148.17" );
you will need to change them.
> # if your router asks for a username and password, use this:
> $t->login("Administrator", "xxx" ) or die "login failed";> # else if it just prompts for a password use this:Read the comments! There are two options here, you only need one. You> $t->waitfor("/Password:/" ) or die "login waitfor 1 failed";
> $t->print("xxx" ) or die "login print failed";
> $t->waitfor("/> /" ) or die "login waitfor 2 failed";
also need to change the password to match that set on your router.
Again, you only need one of these lines.> @lines = $t->cmd("adsl status");
> # or perhaps
> @lines = $t->cmd("adsl info");
And again!> $t->print("system reboot");
> # or perhaps
> $t->print("sys reboot");
--
Alan J. Wylie [url]http://www.wylie.me.uk/[/url]
"Perfection [in design] is achieved not when there is nothing left to add,
but rather when there is nothing left to take away."
-- Antoine de Saint-Exupery
Alan J. Wylie Guest
-
Alan J. Flavell #19
Re: ActivePerl error message? Router script. Please help.Newbie
On Thu, 18 May 2006, l v wrote:
I haven't been following this thread, but it's evident at this point> [email]wrreisen2@yahoo.com[/email] wrote:> > CGI Error
> > The specified CGI application misbehaved by not returning a complete
> > set of HTTP headers. The headers it did return are:
that something is being invoked as a CGI script. My answer is
predicated on that...
More to the point: from a CGI script, you need to return valid CGI> You need to return valid HTTP headers back to your browser in order
> to tell it what to do.
response headers to the web server (see perlfaq9 for a brief
discussion). it's kind-of unfortunate that the error report muddles
up this issue in just the way that many CGI users tend to muddle it
up. The similarity between CGI response header and HTTP response
headers is intentional, but there are subtle differences, and it's
best IMHO to keep a careful grasp on which is which.
It's the server's responsibility to construct a complete and valid set
of HTTP response headers to send to the client/browser - based on the
valid *CGI response* which the server gets from the script.
That is, in its way, a perfectly fine *CGI* response header, together> print "Content-type: text/html\n\n";
with the extra \n which terminates the CGI response headers.
As a valid HTTP header, on the other hand, it would not pass muster,
since the HTTP specification calls for precisely CRLF as line
terminator ( expressed e.g as \015\012 in Perl notation). And anyway
a proper HTTP response calls for more than just a Content-type header.
Furthermore, it's not clear to me that the output was supposed to be
HTML. If it was, in fact, plain text, then the appropriate
content-type would be be text/plain. On the other hand, if it's meant
to be HTML then any data acquired from an external source ought to be
HTML-encoded, or at least carefully filtered, to avoid security
compromises of the kind which is usually, though somewhat
inaccurately, known as "cross site scripting" (XSS).
In any case, any text/* content-type ought to also have its proper
character encoding specified (with appropriate charset= attribute).
best
p.s none of the cross-posted groups seems entirely on-topic for this
CGI discussion, but, out of the ones used, I'm suggesting f'ups to
c.l.p.misc as the best match.
Alan J. Flavell Guest
-
John Bokma #20
Re: ActivePerl error message? Router script. Please help.Newbie
l v <veatchla@yahoo.com> wrote:
[CGI]
Don't do that (or advice that), use the header function that comes with> print "Content-type: text/html\n\n";
CGI.pm. It might stop you from common mistakes (like typing one \n)
--
John Bokma Freelance software developer
&
Experienced Perl programmer: [url]http://castleamber.com/[/url]
John Bokma Guest



Reply With Quote

