[29803] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1046 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 21 03:09:40 2007

Date: Wed, 21 Nov 2007 00:09:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 21 Nov 2007     Volume: 11 Number: 1046

Today's topics:
    Re: firefox could open my cgi, IE will be dead, why? <spamtrap@dot-app.org>
    Re: firefox could open my cgi, IE will be dead, why? <rkb@i.frys.com>
    Re: firefox could open my cgi, IE will be dead, why? <rkb@i.frys.com>
        list context inside term xueweizhong@gmail.com
    Re: list context inside term <krahnj@telus.net>
        new CPAN modules on Wed Nov 21 2007 (Randal Schwartz)
    Re: Script to disconnect Linksys WRT54G wireless router <ben@morrow.me.uk>
    Re: Script to disconnect Linksys WRT54G wireless router <davewilson69@sbcglobal.net>
    Re: Script to disconnect Linksys WRT54G wireless router <davewilson69@sbcglobal.net>
    Re: Script to disconnect Linksys WRT54G wireless router <davewilson69@sbcglobal.net>
    Re: Traversing a set of hashes <jkstill@gmail.com>
    Re: Traversing a set of hashes <jkstill@gmail.com>
    Re: Traversing a set of hashes <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 20 Nov 2007 23:40:10 -0500
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: firefox could open my cgi, IE will be dead, why?
Message-Id: <m1zlx843f9.fsf@dot-app.org>

Big and Blue <No_4@dsl.pipex.com> writes:

>  print $cgi->header(-type=>"text/text", -expires=>'now');
>  ....
>  print <DATA>;
>
> No point putting it into HTML if you don't intend to use it.

The mime type for plain text is text/plain.

sherm--

-- 
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Tue, 20 Nov 2007 22:20:56 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: firefox could open my cgi, IE will be dead, why?
Message-Id: <4de8b284-1c0b-49db-b40f-0b24379273cd@e4g2000hsg.googlegroups.com>

On Nov 19, 10:31 pm, "robertchen...@gmail.com"
<robertchen...@gmail.com> wrote:
> my cgi is very simple, just output the file's content. the file name
> is from another cgi's parameter.
>
> If I use firefox visist the page, no issues at all! Everything looks
> great. But if I use Internet Explorer, the cgi will make IE to die.
> Please help me.
Others have already point out the main issues, but I'll point out a
few that were missed.
>
> #!/tivoli/vendor/perl/bin/perl
Since this is a cgi script that relies on user input, you should be
running in taint mode.

#!/tivoli/vendor/perl/bin/perl -T

> use CGI;
During the testing/debugging phase, you should redirect the fatal
errors and warnings to the browser to aide in troubleshooting.

use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
> #rchen on 4/10
>
> my $cgi = new CGI;
> print $cgi->header(-type=>"text/html", -expires=>'now');
> print $cgi->start_html("Details of the configurations");
warningsToBrowser(1);  # warnings show up as html comments
>
> my $logfile = $cgi->param('logfile');
> open(DATA, "$logfile")|| die("File is not exist!\n");
1) That is very insecure because it allows the user to access files
that they shouldn't.

2) Unless there is a possibility of having spaces in the filename,
there is no need (and most will say you shouldn't) use the quotes
around the var.

3) DATA is one of Perl's reserved filehandles used to read in data
after the __DATA__ or __END__ token.  It should not be used as the
filehandle for accessing the log file.

4) It's preferable to use the 3 arg form of the open call.

5) Especially during debugging, the die statement should include the
error message returned by the OS.

my %logs (log1 => 'path/to/log1',
          log2 => 'path/to/log2',
          log3 => 'path/to/log3',
         );

my $logfile = $cgi->param('logfile');
open( my $logfile, '<', $logs{$logfile} )
     || die "Unable to open $logfile: <$!>\n";

>
> @lines = <DATA>;
>
> foreach $line (@lines) {
>          print "<PRE>$line <\PRE>";
>
> }
>
> close(DATA);
> print $cgi->end_html;



------------------------------

Date: Tue, 20 Nov 2007 22:24:49 -0800 (PST)
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: firefox could open my cgi, IE will be dead, why?
Message-Id: <735348dc-43f4-4761-9b77-dba8a71a2e79@b36g2000hsa.googlegroups.com>

On Nov 20, 10:20 pm, Ron Bergin <r...@i.frys.com> wrote:
>
> my $logfile = $cgi->param('logfile');
> open( my $logfile, '<', $logs{$logfile} )
>      || die "Unable to open $logfile: <$!>\n";
>
Oops, a little correction:

my $logfile = $cgi->param('logfile');
open( my $log, '<', $logs{$logfile} )
     || die "Unable to open $logfile: <$!>\n";


------------------------------

Date: Tue, 20 Nov 2007 23:41:23 -0800 (PST)
From: xueweizhong@gmail.com
Subject: list context inside term
Message-Id: <fe187a1c-72d7-4c75-b1c0-fbb6bd12c6da@p69g2000hsa.googlegroups.com>

Hi perl guys,

Let's discuss 2 expressions here:

1.
>perl -e 'stat (".") [0]'
syntax error at -e line 1, near ") ["

2.
>perl -e '( stat (".") ) [0]'
The 2nd one compiles right.

My question is:

In `( stat (".") ) [0]',  the `()' don't decide the list context, but
`()[0]' decides it a list context. Following this way, in `stat(".")
[0]', why [0] doesn't decide that the left side `stat(".")' is
evaluated in list context?

BTW, the `[]' is not counted as an operator in perlop(in C, it's an
binary operator), it's counted as an term delimiter, so we can
redeclare our questions as:

How to decide the list context inside term?

Best regards
Todd


------------------------------

Date: Wed, 21 Nov 2007 08:04:47 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: list context inside term
Message-Id: <4743E69B.5855348A@telus.net>

xueweizhong@gmail.com wrote:
> 
> Let's discuss 2 expressions here:
> 
> 1.
> >perl -e 'stat (".") [0]'
> syntax error at -e line 1, near ") ["

perldoc perlfunc
[ SNIP ]
       Any function in the list below may be used either with or
       without parentheses around its arguments.  (The syntax
       descriptions omit the parentheses.)  If you use the
       parentheses, the simple (but occasionally surprising) rule
       is this: It looks like a function, therefore it is a
       function, and precedence doesn't matter.  Otherwise it's a
       list operator or unary operator, and precedence does
       matter.  And whitespace between the function and left
       parenthesis doesn't count--so you need to be careful
       sometimes:

           print 1+2+4;        # Prints 7.
           print(1+2) + 4;     # Prints 3.
           print (1+2)+4;      # Also prints 3!
           print +(1+2)+4;     # Prints 7.
           print ((1+2)+4);    # Prints 7.

       If you run Perl with the -w switch it can warn you about
       this.  For example, the third line above produces:

           print (...) interpreted as function at - line 1.
           Useless use of integer addition in void context at - line 1.


> 2.
> >perl -e '( stat (".") ) [0]'
> The 2nd one compiles right.
> 
> My question is:
> 
> In `( stat (".") ) [0]',  the `()' don't decide the list context, but
> `()[0]' decides it a list context. Following this way, in `stat(".")
> [0]', why [0] doesn't decide that the left side `stat(".")' is
> evaluated in list context?

Its a syntax error so it doesn't compile at all so there is no context.


> BTW, the `[]' is not counted as an operator in perlop(in C, it's an
> binary operator), it's counted as an term delimiter, so we can
> redeclare our questions as:
> 
> How to decide the list context inside term?

Context is decided by, well, context.  In a list slice like ( stat "."
)[0] there is of course list context.  If you want it in scalar context
then put it in scalar context:

my $var = stat ".";

if ( stat "." ) {



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Wed, 21 Nov 2007 05:42:14 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Nov 21 2007
Message-Id: <JruD6E.18t9@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Algorithm-Cluster-1.37
http://search.cpan.org/~mdehoon/Algorithm-Cluster-1.37/
Perl interface to the C Clustering Library. 
----
Bio-Das-ProServer-2.070
http://search.cpan.org/~rpettett/Bio-Das-ProServer-2.070/
----
CAM-PDF-1.11
http://search.cpan.org/~cdolan/CAM-PDF-1.11/
PDF manipulation library 
----
Cairo-1.044
http://search.cpan.org/~tsch/Cairo-1.044/
Perl interface to the cairo library 
----
Catalyst-Controller-AllowDisable-0.01
http://search.cpan.org/~tomyhero/Catalyst-Controller-AllowDisable-0.01/
Use when you want to disable your controller. 
----
CatalystX-CRUD-Model-RDBO-0.07
http://search.cpan.org/~karman/CatalystX-CRUD-Model-RDBO-0.07/
Rose::DB::Object CRUD 
----
Class-Std-Fast-0.0.4
http://search.cpan.org/~acid/Class-Std-Fast-0.0.4/
faster but less secure than Class::Std 
----
Crypt-Rijndael-1.05_01
http://search.cpan.org/~bdfoy/Crypt-Rijndael-1.05_01/
Crypt::CBC compliant Rijndael encryption module 
----
DBICx-AutoDoc-0.02
http://search.cpan.org/~jasonk/DBICx-AutoDoc-0.02/
Generate automatic documentation of DBIx::Class::Schema objects 
----
DBICx-AutoDoc-0.03
http://search.cpan.org/~jasonk/DBICx-AutoDoc-0.03/
Generate automatic documentation of DBIx::Class::Schema objects 
----
DateTime-Format-Natural-0.60
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.60/
Create machine readable date/time with natural parsing logic 
----
Devel-CheckOS-1.42
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.42/
check what OS we're running on 
----
Device-VFD-GP1022-0.01
http://search.cpan.org/~yappo/Device-VFD-GP1022-0.01/
GP1022 VFD module controller 
----
Document-Maker-0.020
http://search.cpan.org/~rkrimen/Document-Maker-0.020/
Makefile-like functionality in Perl 
----
Document-Maker-0.021
http://search.cpan.org/~rkrimen/Document-Maker-0.021/
Makefile-like functionality in Perl 
----
Eludia-07.11.19
http://search.cpan.org/~dmow/Eludia-07.11.19/
----
File-CachingFind-0.65
http://search.cpan.org/~dorner/File-CachingFind-0.65/
find files within cached search paths (e.g. include files) 
----
File-Temp-0.19
http://search.cpan.org/~tjenness/File-Temp-0.19/
return name and handle of a temporary file safely 
----
Genezzo-0.72
http://search.cpan.org/~jcohen/Genezzo-0.72/
an extensible database with SQL and DBI 
----
HTML-TreeBuilder-XPath-0.09
http://search.cpan.org/~mirod/HTML-TreeBuilder-XPath-0.09/
add XPath support to HTML::TreeBuilder 
----
Hash-Rename-0.01
http://search.cpan.org/~marcel/Hash-Rename-0.01/
Rename hash keys 
----
IO-Ppoll-0.01
http://search.cpan.org/~pevans/IO-Ppoll-0.01/
Object interface to Linux's ppoll() call 
----
IO-Ppoll-0.02
http://search.cpan.org/~pevans/IO-Ppoll-0.02/
Object interface to Linux's ppoll() call 
----
IPTables-libiptc-0.05
http://search.cpan.org/~hawk/IPTables-libiptc-0.05/
Perl extension for iptables libiptc 
----
LIMS-Controller-1.3
http://search.cpan.org/~cjones/LIMS-Controller-1.3/
Perl object layer controlling the LIMS database and its web interface 
----
LIMS-Controller-1.31
http://search.cpan.org/~cjones/LIMS-Controller-1.31/
Perl object layer controlling the LIMS database and its web interface 
----
Language-Befunge-Debugger-0.3.2
http://search.cpan.org/~jquelin/Language-Befunge-Debugger-0.3.2/
a graphical debugger for Language::Befunge 
----
Lemonldap-Handlers-Generic-3.5.5
http://search.cpan.org/~egerman/Lemonldap-Handlers-Generic-3.5.5/
Perl extension for Lemonldap sso system 
----
Log-Dynamic-0.01
http://search.cpan.org/~jconerly/Log-Dynamic-0.01/
OOish dynamic and customizable logging 
----
Logfile-EPrints-1.18
http://search.cpan.org/~timbrody/Logfile-EPrints-1.18/
Process Web log files for institutional repositories 
----
Microarray-0.26
http://search.cpan.org/~cjones/Microarray-0.26/
A Perl module for creating and manipulating microarray objects 
----
Microarray-0.3
http://search.cpan.org/~cjones/Microarray-0.3/
A Perl module for creating and manipulating microarray objects 
----
Microarray-0.31
http://search.cpan.org/~cjones/Microarray-0.31/
A Perl module for creating and manipulating microarray objects 
----
Module-Release-1.20
http://search.cpan.org/~bdfoy/Module-Release-1.20/
Automate software releases 
----
Module-Which-0.0206
http://search.cpan.org/~ferreira/Module-Which-0.0206/
Finds out which version of Perl modules are installed 
----
MooseX-StrictConstructor-0.03
http://search.cpan.org/~drolsky/MooseX-StrictConstructor-0.03/
Make your object constructors blow up on unknown attributes 
----
Net-Jifty-0.01
http://search.cpan.org/~sartak/Net-Jifty-0.01/
interface to online Jifty applications 
----
Net-Kotonoha-0.03
http://search.cpan.org/~mattn/Net-Kotonoha-0.03/
A perl interface to kotonoha.cc 
----
Net-Kotonoha-0.04
http://search.cpan.org/~mattn/Net-Kotonoha-0.04/
A perl interface to kotonoha.cc 
----
Net-Kotonoha-0.05
http://search.cpan.org/~mattn/Net-Kotonoha-0.05/
A perl interface to kotonoha.cc 
----
Nmap-Parser-1.12
http://search.cpan.org/~apersaud/Nmap-Parser-1.12/
parse nmap scan data with perl 
----
POE-Loop-EV-0.02
http://search.cpan.org/~agrundma/POE-Loop-EV-0.02/
a bridge that supports EV from POE 
----
PPI-1.202_01
http://search.cpan.org/~adamk/PPI-1.202_01/
Parse, Analyze and Manipulate Perl (without perl) 
----
Panotools-Script-0.11
http://search.cpan.org/~bpostle/Panotools-Script-0.11/
Panorama Tools scripting 
----
Parse-Eyapp-1.090
http://search.cpan.org/~casiano/Parse-Eyapp-1.090/
Extensions for Parse::Yapp 
----
Parse-Eyapp-1.091
http://search.cpan.org/~casiano/Parse-Eyapp-1.091/
Extensions for Parse::Yapp 
----
Parse-Marpa-0.001_045
http://search.cpan.org/~jkegl/Parse-Marpa-0.001_045/
(pre-Alpha) Jay Earley's general parsing algorithm, with LR(0) precomputation 
----
Pod-InDesign-TaggedText-0.10
http://search.cpan.org/~bdfoy/Pod-InDesign-TaggedText-0.10/
Turn Pod into Tagged Text 
----
Pod-InDesign-TaggedText-0.11
http://search.cpan.org/~bdfoy/Pod-InDesign-TaggedText-0.11/
Turn Pod into Tagged Text 
----
Pod-InDesign-TaggedText-TPR-0.10
http://search.cpan.org/~bdfoy/Pod-InDesign-TaggedText-TPR-0.10/
----
Pod-SpeakIt-MacSpeech-0.10_01
http://search.cpan.org/~bdfoy/Pod-SpeakIt-MacSpeech-0.10_01/
This is the description 
----
Proc-Queue-1.22
http://search.cpan.org/~salva/Proc-Queue-1.22/
limit the number of child processes running 
----
Signal-StackTrace-0.01
http://search.cpan.org/~lembark/Signal-StackTrace-0.01/
install signal handler to print a stacktrace. 
----
String-LCSS_XS-0.1
http://search.cpan.org/~limaone/String-LCSS_XS-0.1/
Find The Longest Common Substring of Two Strings. 
----
Sub-ForceEval-2.03
http://search.cpan.org/~lembark/Sub-ForceEval-2.03/
eval subroutines, re-throw exceptions if there is an eval; otherwise cluck and return undef. 
----
Sys-Statistics-Linux-0.25
http://search.cpan.org/~bloonix/Sys-Statistics-Linux-0.25/
Front-end module to collect system statistics 
----
Template-Plugin-Iconv-1.00
http://search.cpan.org/~kostya/Template-Plugin-Iconv-1.00/
Text::Iconv for Template Toolkit 
----
Test-Count-0.0103
http://search.cpan.org/~shlomif/Test-Count-0.0103/
Module for keeping track of the number of tests in a Test Script. 
----
Text-Trac-0.08
http://search.cpan.org/~mizzy/Text-Trac-0.08/
Perl extension for formatting text with Trac Wiki Style. 
----
Tk-Canvas-Point-0.05
http://search.cpan.org/~srezic/Tk-Canvas-Point-0.05/
----
Trigger-0.02
http://search.cpan.org/~suzuki/Trigger-0.02/
Trigger framework 
----
UNIVERSAL-ref-0.12
http://search.cpan.org/~jjore/UNIVERSAL-ref-0.12/
Turns ref() into a multimethod 
----
Variable-Magic-0.06
http://search.cpan.org/~vpit/Variable-Magic-0.06/
Associate user-defined magic to variables from Perl. 
----
WWW-Myspace-0.74
http://search.cpan.org/~grantg/WWW-Myspace-0.74/
Access MySpace.com profile information from Perl 
----
XML-Parser-2.36
http://search.cpan.org/~msergeant/XML-Parser-2.36/
A perl module for parsing XML documents 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Wed, 21 Nov 2007 02:08:41 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Script to disconnect Linksys WRT54G wireless router on Windows
Message-Id: <9igc15-a9g.ln1@osiris.mauzo.dyndns.org>


Quoth Wilson <davewilson69@sbcglobal.net>:
> It's not working yet - but it's closer than it was 
> Here is the tutorial so far.
> 
> STEP 1:
> Install ActiveState activeperl freeware on Windows XP
> http://www.activestate.com/Products/activeperl
> 
> STEP 2:
> Modify script to use YOUR password for your Linksys WRT54G router review
> 
> STEP 3:
> Run script
> 
> At this point, I get the following error. 
> I will google for this package and see if I can find it on the web.
> 
> 501 Protocol scheme 'https' is not supported (Crypt::SSLeay not installed)

Under ActivePerl you can install Crypt::SSLeay with

    C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd

> #!/usr/bin/perl -w
> use strict;

    use warnings;

is better than -w nowadays.

> my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this
> # my $user='root';
> my $user=''; # the Linksys WRT54G wireless router doesn't have login name
> my $pass='letmein';
> # make a User Agent
> use LWP::UserAgent;
> my $ua = LWP::UserAgent->new;
> # make a request object
> # fill in the button name and value from
> # looking at the page source.
> my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']);

Huh? You surely want to do something with this request, like submit it
to $ua?

Ben



------------------------------

Date: Tue, 20 Nov 2007 21:30:44 -0800
From: Wilson <davewilson69@sbcglobal.net>
Subject: Re: Script to disconnect Linksys WRT54G wireless router on Windows
Message-Id: <JpP0j.362$NY.189@nlpi068.nbdc.sbc.com>

On Wed, 21 Nov 2007 02:08:41 +0000, Ben Morrow wrote:
> Under ActivePerl you can install Crypt::SSLeay with
>     C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd

Hi Ben,
Your suggestion is very helpful as I was clueless as to the next step.

I hope to write up a short tutorial to help others, so, in the spirit of
the tutorial, here is the output from your suggested "ppm" command
(whatever that is)...

I'm not sure what I just did, but a lot happened when I ran:
C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd

See below for the log file.
Wilson



Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd
Syncing site PPM database with .packlists...done
Downloading Crypt-SSLeay-0.53...done
Unpacking Crypt-SSLeay-0.53...done
Generating HTML for Crypt-SSLeay-0.53...done
Updating files in site area...done
Downloading Crypt-SSLeay-0.53 install script...done
Running Crypt-SSLeay-0.53 install script...
**************************************************************************
This software package uses strong cryptography, so even if it is created,
maintained and distributed from countries where it is legal to do this,
it falls under certain export/import and/or use restrictions in some
other parts of the world.

PLEASE REMEMBER THAT EXPORT/IMPORT AND/OR USE OF STRONG CRYPTOGRAPHY
SOFTWARE, PROVIDING CRYPTOGRAPHY HOOKS OR EVEN JUST COMMUNICATING
TECHNICAL DETAILS ABOUT CRYPTOGRAPHY SOFTWARE IS ILLEGAL IN SOME PARTS
OF THE WORLD. SO, WHEN YOU IMPORT THIS PACKAGE TO YOUR COUNTRY,
RE-DISTRIBUTE IT FROM THERE OR EVEN JUST EMAIL TECHNICAL SUGGESTIONS
OR EVEN SOURCE PATCHES TO THE AUTHOR OR OTHER PEOPLE YOU ARE STRONGLY
ADVISED TO PAY CLOSE ATTENTION TO ANY EXPORT/IMPORT AND/OR USE LAWS
WHICH APPLY TO YOU. THE AUTHORS OF OPENSSL ARE NOT LIABLE FOR ANY
VIOLATIONS YOU MAKE HERE. SO BE CAREFUL, IT IS YOUR RESPONSIBILITY.

CREDIT INFORMATION: This product includes cryptographic software
written by Eric A. Young (eay@cryptsoft.com). This product
includes software written by Tim J. Hudson (tjh@cryptsoft.com).
**************************************************************************

Proceed with installation? [yes]

A copy of the needed library ssleay32.dll was found in
C:\WINDOWS\system32\ssleay32.dll. 
If this is compatible with the version (0.9.8a)
used to compile the Perl module, all that is needed to
complete the installation is to ensure
C:\WINDOWS\system32\ssleay32.dll is in your PATH environment variable.

Fetch ssleay32.dll? [no]
Aborting download of ssleay32.dll.
done
  13 files installed

C:\>



------------------------------

Date: Wed, 21 Nov 2007 05:52:24 GMT
From: Wilson <davewilson69@sbcglobal.net>
Subject: Re: Script to disconnect Linksys WRT54G wireless router on Windows
Message-Id: <sIP0j.60428$RX.44370@newssvr11.news.prodigy.net>

On Wed, 21 Nov 2007 02:08:41 +0000, Ben Morrow wrote:
>> my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']);
> Huh? You surely want to do something with this request, like submit it
> to $ua?

Hi Ben,
I'm pretty confused about this part as I do not know Perl.

The original script I found googling did a "reboot" of the router.

I modified that original script to attempt to do a "disconnect" and then
five seconds later to do a "connect" (assuming I have the name of the
buttons correct for the Linksys WRT54G wireless router).

Here is the original script, in its entirety.
Does this original script perform "something" with the request?

Wilson


#!/usr/bin/perl -w
use strict;

# check out this documentation:
# first, the cookbook
# http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod
# the LWP reference
# http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP.pm
# oh but this is JUST what we want
# http://lwp.interglacial.com/ch05_05.htm

my $adr='https://192.168.0.1/Services.asp'; # talk to this
my $user='root';
my $pass='mypasswd';

# make a User Agent
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;

# make a request object
# fill in the button name and value from
# looking at the page source.
# DD-WRT puts out a complicated page with Javascript that
# I don't understand how to deal with, so this doesn't work,
# but in principle (if I knew what to put in for action and reboot)
# it should.
my $req = HTTP::Request->new(POST => $adr,
			     ['action','reboot']);

$req->authorization_basic($user, $pass);

# send the request
my $result = $ua->request($req);


# print the result
print $result->as_string;


------------------------------

Date: Wed, 21 Nov 2007 06:33:30 GMT
From: Wilson <davewilson69@sbcglobal.net>
Subject: Re: Script to disconnect Linksys WRT54G wireless router on Windows
Message-Id: <_iQ0j.22612$lD6.14412@newssvr27.news.prodigy.net>

Well, I didn't get any results back yet and it's still not working but I'll
keep trying things .....

C:\freeware\perl>router.pl
500 Server closed connection without sending any data back
Content-Type: text/plain
Client-Date: Wed, 21 Nov 2007 06:10:15 GMT
Client-Warning: Internal response

500 Server closed connection without sending any data back

Here is the tutorial so far ....... (note it doesn't work yet) ......
All I'm trying to do is disconnect and reconnect using a command line
script.

Any and all help for this tutorial is appreciated as this is my very first
perl program ever.

Wilson

-----------------------------------------------------------------
How to control your wireless router from the Windows command line
-----------------------------------------------------------------
0. Obtain the basic Perl script to reboot the Linksys WRT54G:
   (see sample Perl script below)
-----------------------------------------------------------------
1. Install ActiveState activeperl freeware on Windows XP:
    http://www.activestate.com/Products/activeperl

   For example, install the msi file into c:\freeware\activeperl
-----------------------------------------------------------------
2. Install "Crypt::SSLeay" under ActivePerl using ppm commands:
    c:\> cd c:\freeware\activeperl
    c:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd 
-----------------------------------------------------------------
3. Install Win32 OpenSSL freeware support for https URLs
    http://www.openssl.org/related/binaries.html 

   For example, install into c:\freeware\activeperl\win32openssl
-----------------------------------------------------------------
4. Make sure both Perl is in your Windows PATH shell variable:
    Start » Settings » Control Panel » System » Advanced » 
    Environment Variables » System variables » Path
-----------------------------------------------------------------
5. Test Win32 OpenSSL on Windows from the command line:
    c:\> openssl version [hit Enter]
    c:\> openssl s_client -connect www.openssl.org:443 [hit Enter]
    GET / HTTP/1.0 [hit Enter twice] 
-----------------------------------------------------------------
6. Modify this script to press desired buttons on your router
#!/usr/bin/perl -w
use strict;

# check out this documentation:
# first, the cookbook
# http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod
# the LWP reference
# http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP.pm
# oh but this is JUST what we want
# http://lwp.interglacial.com/ch05_05.htm

my $adr='https://192.168.0.1/Services.asp'; # talk to this
my $user='root';
my $pass='mypasswd';

# make a User Agent
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;

# make a request object
# fill in the button name and value from
# looking at the page source.
# DD-WRT puts out a complicated page with Javascript that
# I don't understand how to deal with, so this doesn't work,
# but in principle (if I knew what to put in for action and reboot)
# it should.
my $req = HTTP::Request->new(POST => $adr,
			     ['action','reboot']);

$req->authorization_basic($user, $pass);

# send the request
my $result = $ua->request($req);


# print the result
print $result->as_string;
-----------------------------------------------------------------
7. Here is a modified script intended to disconnect & reconnect:

#!/usr/bin/perl 
use strict;
use warnings;

# check out this documentation:
# first, the cookbook
# http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod
# the LWP reference
# http://search.cpan.org/~gaas/libwww-perl-5.805/lib/LWP.pm
# oh but this is JUST what we want
# http://lwp.interglacial.com/ch05_05.htm

# my $adr='https://192.168.0.1/Services.asp'; # talk to this
my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this

# my $user='root';
my $user=''; # the Linksys WRT54G wireless router doesn't have login name

# my $pass='mypassword';
my $pass='letmein';

# make a User Agent
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;

# make a request object
# fill in the button name and value from
# looking at the page source.
# DD-WRT puts out a complicated page with Javascript that
# I don't understand how to deal with, so this doesn't work,
# but in principle (if I knew what to put in for action and reboot)
# it should.
# my $req = HTTP::Request->new(POST => $adr,
#                            ['action','reboot']);
# A view source on the browser web page seems to indicate the disconnect
# button is named "disconnect" so I'll substitute that instead of "reboot".
my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']);

# Wait 5 seconds - then reconnect as this will get you a new IP address
sleep 5;

my $req = HTTP::Request->new(POST => $adr, ['action','connect']);

$req->authorization_basic($user, $pass);

# send the request
my $result = $ua->request($req);

# print the result
print $result->as_string;

# The end of a perl script to run on Windows to tell the Linksys WRT54G
# router to disconnect from the ISP; then after 5 seconds, to reconnect.
-----------------------------------------------------------------
-----------------------------------------------------------------


------------------------------

Date: Tue, 20 Nov 2007 18:33:04 -0800 (PST)
From: jkstill <jkstill@gmail.com>
Subject: Re: Traversing a set of hashes
Message-Id: <97d231b9-e6c4-4a0d-8d58-86589d9cb93b@d27g2000prf.googlegroups.com>

On Nov 20, 5:14 pm, "jl_p...@hotmail.com" <jl_p...@hotmail.com> wrote:
>
> This is what you want, isn't it?

Well, no, not actually.

All possible combinations of the three.
That would be 8 combinations of values each from each of the 3 nested
hashes.

I should have explained more clearly.

Thanks for the reply.


------------------------------

Date: Tue, 20 Nov 2007 18:39:15 -0800 (PST)
From: jkstill <jkstill@gmail.com>
Subject: Re: Traversing a set of hashes
Message-Id: <c6fee743-1ee8-47c3-a1e4-51b2decc45c5@a39g2000pre.googlegroups.com>

On Nov 20, 5:32 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>>
> So you do mean what I said... the first thing to realize is that your
> data structure should be arrays, not hashes:
>
>     [  ['f_zero', 'f_one'], ['s_zero', 's_one']  ]
>
> since you don't make use of the keys.

This is just a prototype used to understand how to build something
else.
I need the hashes. :)

>
> The first thing that come to (my) mind is recursion, but of course you
> can do it with loops as well. You only need three nested loops to handle
> any number of cases.
>
>
Excellent!  This does exactly what I need.

I'll play with it so I can understand how it works.

Jared



------------------------------

Date: Wed, 21 Nov 2007 02:37:42 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Traversing a set of hashes
Message-Id: <m8ic15-deg.ln1@osiris.mauzo.dyndns.org>


Quoth Ben Morrow <ben@morrow.me.uk>:
>
>     use List::Util qw/reduce/;
> 
>     my @lol = map [sort values %$_], sort values %h;
>     my $first = shift @lol;
> 
>     our ($a, $b); # silence warnings
> 
>     print @$_ for @{
>         reduce {        # one...
>             [
>                 map {   # two...
>                     my $tmp = $_;
>                     map [$tmp, @$_], @$a;   # three loops
>                 } @$b
>             ]
>         } [map [$_], @$first], @lol     # (this map doesn't count ;) )
>     };

Duh, I don't need to special-case the first item, just start with the
appropriate identity. Then it becomes a one-liner (always nice):

    print @$_ for @{
        reduce {
            [
                map {
                    my $tmp = $_;
                    map [$tmp, @$_], @$a;
                } @$b
            ]
        } [ [] ], map [sort values %$_], sort values %h
    };

Ben



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1046
***************************************


home help back first fref pref prev next nref lref last post