Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What is going on?

Reply
Thread Tools

What is going on?

 
 
giraffe6044@gmail.com
Guest
Posts: n/a
 
      04-15-2005
I was given this perl script as a example of a program to control our
remote powerdevices. Problem is i do not know Perl. I am creating the
site in Coldfusion
Can someone help explain to me what this script is doing to get the
STATUS of the RPS.

is it a form post? or is it requesting a URL and if so what URL.

here is the device.
http://www.digital-loggers.com/EPC.html

Thank you very much for any help

#!/usr/bin/perl -w
#----------------------------------------------------------------------
use LWP::UserAgent;
#----------------------------------------------------------------------
$ua = LWP::UserAgent->new();
#----------------------------------------------------------------------

if ($#ARGV <= 1)
{
print STDERR 'Usage: UserUtil <Host>[ort] <loginassword>
<[n]{on|off|pulse|status}> ...'."\n";
exit -1;
}
($epc, $auth)=splice(@ARGV,0,2);
$base='http://'.$auth.'@'.$epc.'/';

foreach (@ARGV)
{
$_=lc;
s/(^[^1-8])/a$1/;
if (/^([1-8a])on$/)
{
RelLink('outleton?'.$1);
}
elsif (/^([1-8a])off$/)
{
RelLink('outletoff?'.$1);
}
elsif (/^([1-8a])pulse$/)
{
RelLink('outletgl?'.$1);
}
elsif (/^([1-8a])status$/)
{
$n=$1;
defined($response) && ($response->content =~/<a href=outleto/) ||
RelLink('');
$content=$response->content;
while ($content =~ /<a href=outlet(on|off)\?([1-8])>/ig)
{
if (($2 eq $n) || ($n eq 'a'))
{
if ($1 eq "on")
{print $2," OFF\n";}
else
{print $2," ON\n";}
}
}
}
else
{
die "Unknown command $_\n";
}
}

sub RelLink
{
local ($_) = @_;
#print STDERR $base.$_,"\n";
$response = $ua->get($base.$_);
$response->is_error() && die $response->status_line;
}

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      04-15-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:


> Subject: What is going on?



You will greatly increase the chances of getting your question
answered if you put the subject of your article in the Subject
of your article.


> I was given this perl script as a example of a program to control our
> remote powerdevices. Problem is i do not know Perl.



You could learn Perl or you could hire someone who knows Perl or
you could ask whoever provided you with that code.


> Can someone help explain to me what this script is doing to get the
> STATUS of the RPS.



What is an "RPS" ?


> is it a form post?



It makes an HTTP GET request.


> or is it requesting a URL



Even POST requests a URL.

I think you don't understand HTTP, perhaps you should read up
on it a bit.



> use LWP::UserAgent;



Did you try reading the documentation for the module being used?


> $response = $ua->get($base.$_);

^^^
^^^

Clearly a GET request.


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
OT: Windows XP: Going, going ... gone? OTHMAN MCSE 2 03-25-2008 04:45 PM
XP search going all lame on me..explorer going crazy when trying tosearch. fotoobscura Computer Support 8 01-12-2008 01:09 AM
Firefighters at the site of WTC7 "Move away the building is going to blow up, get back the building is going to blow up." Midex Python 24 05-07-2007 04:23 AM
floppy drive just keeps on going and going and ... Weylon Bulloch Computer Support 1 09-07-2003 07:17 AM
VPN going up but traffic going one way PLP Cisco 1 07-11-2003 08:28 AM



Advertisments