[32481] in Perl-Users-Digest
Perl-Users Digest, Issue: 3746 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 29 03:09:21 2012
Date: Sun, 29 Jul 2012 00:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 29 Jul 2012 Volume: 11 Number: 3746
Today's topics:
A perl-html quine <cal@example.invalid>
A timeout question using Net::FTP <trudge@gmail.com>
Re: A timeout question using Net::FTP <ben@morrow.me.uk>
Re: A timeout question using Net::FTP <trudge@gmail.com>
I killed my own source. <cal@example.invalid>
Re: I killed my own source. <ben@morrow.me.uk>
Re: I killed my own source. <news@lawshouse.org>
Re: I killed my own source. <cal@example.invalid>
Re: Linux, IO::Socket::INET and recv'ing broadcasted UD <hjp-usenet2@hjp.at>
Re: Linux, IO::Socket::INET and recv'ing broadcasted UD <ben@morrow.me.uk>
Re: Regx explanation please <hjp-usenet2@hjp.at>
Re: Regx explanation please <dave@invalid.invalid>
Re: Regx explanation please <ben@morrow.me.uk>
web service <nospam.gravitalsun.antispam@hotmail.com.nospam>
Re: web service <rweikusat@mssgmbh.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 28 Jul 2012 23:27:01 -0600
From: Cal Dershowitz <cal@example.invalid>
Subject: A perl-html quine
Message-Id: <LpKdnY6r1_M4VInNnZ2dnUVZ_gednZ2d@supernews.com>
On 07/28/2012 03:29 PM, Henry Law wrote:
> Cal, this isn't a well-posed question. In fact I have no idea what
> you're trying to do and what you ended up doing instead.
I was trying verify if a person could do what I've now put in the
subject, but my first problem was that I killed my source. I had the
the arrow going this way > instead of this way < in the open statement:
bye bye source.
>
> I've looked at your program (it's not runnable and I'm not going to
> invest the effort required to make it so) and I can't immediately see
> any reason why it should over-write its own source.
>
> What's "argv" (actually ARGV in Perl) got to do with it?
>
> A "source file"? Source for what? Do you mean "an HTML file"?
>
> And I have no clue what you want to do when you talk about random
> compositions of friendly letters in a character class. What's "friendly"
> in this context? What character class?
>
> If your reply looks interesting and makes clearer what you're trying to
> do I'll have a go at it. Unless you're a bot, that is ...
>
Not a bot, henry, JAPH.
$ cat lp3.pl
#!/usr/bin/perl -w
use strict;
use 5.010;
use Net::FTP;
my $domain = 'www.merrillpjensen.com';
my $username = '';
my $password = '';
my $sourcefile = $0;
# get some ramdom letters
my $word_length = 5;
my $word = &generate_random_string($word_length);
print "Random string: " . $word . "\n";
print "Length: " . length($word) . "\n";
my $ftp = Net::FTP->new( $domain, Debug => 1, Passive => 1 )
or die "Can't connect: $@\n";
$ftp->login( $username, $password ) or die "Couldn't login\n";
$ftp->binary();
# get files from remote root that end in html:
my @remote_files = $ftp->ls();
# print "remote files are: @remote_files\n";
my @matching = map /${word}_(\d+)\.html/, @remote_files;
print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
my $winner = pop @matching;
my $newnum1 = $winner + 1;
my $html_file = "${word}_$newnum1.html";
print "html file is $html_file\n";
# create file for html stubouts
open( my $fh, '>', $html_file )
or die("Can't open $html_file for writing: $!");
print $fh "<Content-Type: text/html>\n";
print $fh "<html>\n";
print $fh "<head>\n";
print $fh "<title>" . $sourcefile . "</title>\n";
print $fh "</head>\n";
print $fh "<body bgcolor=white>\n";
print $fh "<h1>Source Listing</h1>\n";
# get files from Desktop/images/
my $path = '/home/dan/Desktop/upload/';
my @files = <$path*>;
# get ls from remote image directory
$ftp->cwd('/images/') or die "cwd failed $@\n";
my @list = $ftp->ls();
# main control
for my $name (@files) {
print "name is $name\n";
my ($ext) = $name =~ /([^.]*)$/;
print "ext is $ext\n";
@matching = map /image_(\d+)\.$ext$/, @list;
# print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
$winner = pop @matching;
my $newnum = $winner + 1;
my $new_file2 = "image_$newnum.$ext";
print "newfile is $new_file2\n";
$ftp->put( $name, $new_file2 ) or die "put failed $!\n";
push( @list, $new_file2 );
# unlink($name);
print $fh "<img src=\"/images/$new_file2\"/>\n\n";
print $fh "<p>caption for $new_file2 <\/p>\n";
}
open( my $gh, '<', $sourcefile )
or die("Can't open $sourcefile for writing: $!");
while (<$gh>) {
chomp;
# replace things that look like diamonds with html literals
s/</' < '/;
s/>/' > '/;
# this may look obvious, but it's not
s/my \$password = '.*';/my \$password = 'redacted';/;
s/my \$username = '.*';/my \$username = 'redacted';/;
print $fh '<p>' . $_ . '</p>' . "\n";
}
close $gh;
close $fh;
$ftp->cdup() or die "cdup failed $@\n";
$ftp->put($html_file) or die "put failed $@\n";
my @r = $ftp->ls();
# print "@r\n";
###########################################################
# Written by Guy Malachi http://guymal.com
# 18 August, 2002
###########################################################
# This function generates random strings of a given length
sub generate_random_string {
my $length_of_randomstring = shift; # the length of
# the random string to generate
my @chars = ( 'a' .. 'z' );
my $random_string;
foreach ( 1 .. $length_of_randomstring ) {
# rand @chars will generate a random
# number between 0 and scalar @chars
$random_string .= $chars[ rand @chars ];
}
return $random_string;
}
$
So, this almost works, and I think my trouble is with the regex for
substituting out the password and user name. Sometimes it works;
sometimes it doesn't:
http://www.merrillpjensen.com/ifeod_2.html
It seems like the wheels fall off the RE engine when I add the
subroutine. But I'm really proud of this so far. I had all the time I
wanted at night to read for the last few weeks and had only _Learning
Perl_ to read. No tv, 'puter, cell phone. A very well-crafted book.
--
Cal
------------------------------
Date: Fri, 27 Jul 2012 19:13:52 -0700 (PDT)
From: Trudge <trudge@gmail.com>
Subject: A timeout question using Net::FTP
Message-Id: <c6d3c1f5-44b8-4333-8ea3-ea0fc1be1c33@googlegroups.com>
I have a script to download files. It checks the remote and local directories, and downloads any new files from the remote location.
Here is part of my code:
my $ftp = Net::FTP->new
(
"ftp.xxx.yy",
Timeout => 3600,
Debug => 0
) or die "Could not connect: $@\n";
My question is, what units are the Timeout option in? The docs don't make it clear, and I'm guessing the units are seconds. Anyone have a definitive answer?
--
------------------------------
Date: Sat, 28 Jul 2012 12:23:56 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: A timeout question using Net::FTP
Message-Id: <cnuce9-g03.ln1@anubis.morrow.me.uk>
Quoth Trudge <trudge@gmail.com>:
> I have a script to download files. It checks the remote and local
> directories, and downloads any new files from the remote location.
>
> Here is part of my code:
> my $ftp = Net::FTP->new
> (
> "ftp.xxx.yy",
> Timeout => 3600,
> Debug => 0
> ) or die "Could not connect: $@\n";
>
> My question is, what units are the Timeout option in? The docs don't
> make it clear, and I'm guessing the units are seconds. Anyone have a
> definitive answer?
The timeout is passed to IO::Select, so it's in seconds, possibly
fractional.
Ben
------------------------------
Date: Sat, 28 Jul 2012 10:04:48 -0700 (PDT)
From: Trudge <trudge@gmail.com>
Subject: Re: A timeout question using Net::FTP
Message-Id: <6d2cf14b-e291-400e-8841-f62ef123bc54@googlegroups.com>
On Saturday, July 28, 2012 7:23:56 AM UTC-4, Ben Morrow wrote:
> Quoth Trudge:
>
> > I have a script to download files. It checks the remote and local
>
> > directories, and downloads any new files from the remote location.
>
> >
>
> > Here is part of my code:
>
> > my $ftp = Net::FTP->new
>
> > (
>
> > "ftp.xxx.yy",
>
> > Timeout => 3600,
>
> > Debug => 0
>
> > ) or die "Could not connect: $@\n";
>
> >
>
> > My question is, what units are the Timeout option in? The docs don't
>
> > make it clear, and I'm guessing the units are seconds. Anyone have a
>
> > definitive answer?
>
>
>
> The timeout is passed to IO::Select, so it's in seconds, possibly
>
> fractional.
>
>
>
> Ben
Thank you Ben (again) for clearing something up for myself and possibly others. That gives me a starting point.
--
Amer Neely
------------------------------
Date: Sat, 28 Jul 2012 04:51:35 -0600
From: Cal Dershowitz <cal@example.invalid>
Subject: I killed my own source.
Message-Id: <xOKdnesR4qWoWY7NnZ2dnUVZ_t-dnZ2d@supernews.com>
Net::FTP=GLOB(0x837217c)<<< 226 Transfer complete
. .. logs index.html wsb6121022001 energy green2.m4v Video 151.wmv
false.wmv vids images zen rev1.html luther1.html lh_1.html lh_17.html
lh_18.html lh_19.html ceiling_2.html ceiling_2_files {word}_2.html
{la_veta}_2.html la_veta1.html la_veta2.html la_veta3.html la_veta4.html
la_veta5.html la_veta6.html lh_abc_2.html
$ echo 'piss on it, I'll do itagain'
>
> C^C
$ perl ceiling4.pl
Net::FTP>>> Net::FTP(2.77)
[blobbity bla]
(74,208,244,112,254,89).
Net::FTP=GLOB(0x9dad8d4)>>> NLST
Net::FTP=GLOB(0x9dad8d4)<<< 150 Opening BINARY mode data connection for
file list
Net::FTP=GLOB(0x9dad8d4)<<< 226 Transfer complete
. .. logs index.html wsb6121022001 energy green2.m4v Video 151.wmv
false.wmv vids images zen rev1.html luther1.html lh_1.html lh_17.html
lh_18.html lh_19.html ceiling_2.html ceiling_2_files {word}_2.html
{la_veta}_2.html la_veta1.html la_veta2.html la_veta3.html la_veta4.html
la_veta5.html la_veta6.html lh_abc_2.html lh_abc_3.html
$ cat lh_abc_3.html
<html>
<head>
<title>Lutherhaven Renovation</title>
</head>
<body bgcolor=white>
<h1>Basement Ceiling Materials</h1>
<img src="/images/image_62.jpg"/>
<p>caption for image_62.jpg </p>
<img src="/images/image_63.jpg"/>
<p>caption for image_63.jpg </p>
<img src="/images/image_64.jpg"/>
<p>caption for image_64.jpg </p>
<img src="/images/image_65.jpg"/>
<p>caption for image_65.jpg </p>
<img src="/images/image_66.jpg"/>
<p>caption for image_66.jpg </p>
$ cat ceiling4.pl
$ cat ceiling4.pl
$ echo "I murdered my source."
I murdered my source.
$ ls -l
total 145524
-rw-r--r-- 1 dan dan 2359350 2011-11-06 16:59 1and1.bmp
-rw-r--r-- 1 dan dan 66174 2012-01-10 20:03
402789_2985747999782_1144491549_33319470_913147571_n.jpg
-rw-r--r-- 1 dan dan 26886706 2011-10-14 22:47 abq1.wmv
-rw-r--r-- 1 dan dan 688 2011-11-07 16:55 agd1.html
-rw-r--r-- 1 dan dan 102369 2012-01-10 02:15 agd1.jpg
-rw-r--r-- 1 dan dan 673 2011-11-12 17:21 agd2.html
-rw-r--r-- 1 dan dan 92055 2012-01-10 02:15 agd.jpg
-rw-rw-r-- 1 dan dan 143 2012-06-12 15:23 andrea1.pl
-rw-rw-r-- 1 dan dan 103 2012-06-12 15:22 andrea1.pl~
-rw-r--r-- 1 dan dan 1748 2011-10-11 21:39 beck1.txt
-rw-r--r-- 1 dan dan 896 2011-06-22 13:27 bill1.txt
-rw-r--r-- 1 dan dan 2810 2011-07-06 18:32 BOOTEX.LOG
-rw-rw-r-- 1 dan dan 2090 2012-07-04 01:09 ceiling1.pl
-rw-rw-r-- 1 dan dan 2090 2012-06-25 14:42 ceiling1.pl~
-rw-rw-r-- 1 dan dan 457 2012-06-25 14:42 ceiling_2.html
-rw-rw-r-- 1 dan dan 2107 2012-07-03 23:53 ceiling2.pl
-rw-rw-r-- 1 dan dan 2106 2012-07-03 23:52 ceiling2.pl~
-rw-rw-r-- 1 dan dan 2109 2012-07-27 18:07 ceiling3.pl
-rw-rw-r-- 1 dan dan 2107 2012-07-27 18:07 ceiling3.pl~
-rw-rw-r-- 1 dan dan 0 2012-07-28 04:08 ceiling4.pl
-rw-rw-r-- 1 dan dan 2085 2012-07-27 21:26 ceiling4.pl~
[snip]
$ cat ceiling4.pl~
#!/usr/bin/perl -w
use strict;
use 5.010;
use Net::FTP;
my $domain = 'www.merrillpjensen.com';
my $username = 'u61210220';
my $password = '';
my $word = "lh_abc";
my $ftp = Net::FTP->new( $domain, Debug => 1, Passive => 1 )
or die "Can't connect: $@\n";
$ftp->login( $username, $password ) or die "Couldn't login\n";
$ftp->binary();
# get files from remote root that end in html:
my @remote_files = $ftp->ls();
# print "remote files are: @remote_files\n";
my @matching = map /${word}_(\d+)\.html/, @remote_files;
print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
my $winner = pop @matching;
my $newnum1 = $winner + 1;
my $html_file = "${word}_$newnum1.html";
print "html file is $html_file\n";
# create file for html stubouts
open( my $fh, '>', $html_file )
or die("Can't open $html_file for writing: $!");
print $fh "<html>\n";
print $fh "<head>\n";
print $fh "<title>Lutherhaven Renovation</title>\n";
print $fh "</head>\n";
print $fh "<body bgcolor=white>\n";
print $fh "<h1>Basement Ceiling Materials</h1>\n";
# get files from Desktop/images/
my $path = '/home/dan/Desktop/upload/';
my @files = <$path*>;
# get ls from remote image directory
$ftp->cwd('/images/') or die "cwd failed $@\n";
my @list = $ftp->ls();
# main control
for my $name (@files) {
print "name is $name\n";
my ($ext) = $name =~ /([^.]*)$/;
print "ext is $ext\n";
@matching = map /image_(\d+)\.$ext$/, @list;
print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
$winner = pop @matching;
my $newnum = $winner + 1;
my $new_file2 = "image_$newnum.$ext";
print "newfile is $new_file2\n";
$ftp->put( $name, $new_file2 ) or die "put failed $!\n";
push( @list, $new_file2 );
# unlink($name);
print $fh "<img src=\"/images/$new_file2\"/>\n\n";
print $fh "<p>caption for $new_file2 <\/p>\n";
}
close $fh;
$ftp->cdup() or die "cdup failed $@\n";
$ftp->put($html_file) or die "put failed $@\n";
my @r = $ftp->ls();
print "@r\n";
$
What I tried to do was to write a source file to output. Does argv
contain the prog's name?
How would I switch _abc_ for a random composition of friendly letters in
a character class?
I can take the easier route and look at script n-1, too.
Peace.
--
Cal
------------------------------
Date: Sat, 28 Jul 2012 12:28:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I killed my own source.
Message-Id: <i0vce9-g03.ln1@anubis.morrow.me.uk>
Quoth Cal Dershowitz <cal@example.invalid>:
<snip>
I don't understand what any of that's supposed to be doing, or what it's
doing wrong...
> What I tried to do was to write a source file to output. Does argv
> contain the prog's name?
No. The program's name is in $0, and it may or may not be an absolute
path depending on how it was invoked.
> How would I switch _abc_ for a random composition of friendly letters in
> a character class?
What do you mean?
Ben
------------------------------
Date: Sat, 28 Jul 2012 22:29:10 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: I killed my own source.
Message-Id: <DJydnTtkveI7xInNnZ2dnUVZ8g6dnZ2d@giganews.com>
On 28/07/12 11:51, Cal Dershowitz wrote:
snipped tedious console listing. A couple of lines of explanation would
have been better.
> $ cat ceiling4.pl
> $ cat ceiling4.pl
> $ echo "I murdered my source."
> I murdered my source.
snipped unnecessary directory listing.
> $ cat ceiling4.pl~
Snipped Perl listing which looked OK at a glance.
> What I tried to do was to write a source file to output. Does argv
> contain the prog's name?
>
> How would I switch _abc_ for a random composition of friendly letters in
> a character class?
>
> I can take the easier route and look at script n-1, too.
Cal, this isn't a well-posed question. In fact I have no idea what
you're trying to do and what you ended up doing instead.
I've looked at your program (it's not runnable and I'm not going to
invest the effort required to make it so) and I can't immediately see
any reason why it should over-write its own source.
What's "argv" (actually ARGV in Perl) got to do with it?
A "source file"? Source for what? Do you mean "an HTML file"?
And I have no clue what you want to do when you talk about random
compositions of friendly letters in a character class. What's
"friendly" in this context? What character class?
If your reply looks interesting and makes clearer what you're trying to
do I'll have a go at it. Unless you're a bot, that is ...
--
Henry Law Manchester, England
------------------------------
Date: Sat, 28 Jul 2012 15:42:04 -0600
From: Cal Dershowitz <cal@example.invalid>
Subject: Re: I killed my own source.
Message-Id: <XL6dnT3rX4A0wYnNnZ2dnUVZ_jWdnZ2d@supernews.com>
On 07/28/2012 05:28 AM, Ben Morrow wrote:
>
> Quoth Cal Dershowitz<cal@example.invalid>:
> <snip>
>
> I don't understand what any of that's supposed to be doing, or what it's
> doing wrong...
It's been a question I've been tossing around here, as in the C world,
this would be UB.
Net::FTP=GLOB(0x9df1948)<<< 226 Transfer complete
. .. logs index.html wsb6121022001 energy green2.m4v Video 151.wmv
false.wmv vids images zen rev1.html luther1.html lh_1.html lh_17.html
lh_18.html lh_19.html ceiling_2.html ceiling_2_files {word}_2.html
{la_veta}_2.html la_veta1.html la_veta2.html la_veta3.html la_veta4.html
la_veta5.html la_veta6.html lh_abc_2.html lh_abc_3.html jdwrt__2.html
$ cat ceiling5.pl
#!/usr/bin/perl -w
use strict;
use 5.010;
use Net::FTP;
my $domain = 'www.merrillpjensen.com';
my $username = '';
my $password = '';
my $word = "jdwrt_";
my $ftp = Net::FTP->new( $domain, Debug => 1, Passive => 1 )
or die "Can't connect: $@\n";
$ftp->login( $username, $password ) or die "Couldn't login\n";
$ftp->binary();
# get files from remote root that end in html:
my @remote_files = $ftp->ls();
# print "remote files are: @remote_files\n";
my @matching = map /${word}_(\d+)\.html/, @remote_files;
print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
my $winner = pop @matching;
my $newnum1 = $winner + 1;
my $html_file = "${word}_$newnum1.html";
print "html file is $html_file\n";
# create file for html stubouts
open( my $fh, '>', $html_file )
or die("Can't open $html_file for writing: $!");
print $fh "<html>\n";
print $fh "<head>\n";
print $fh "<title>Lutherhaven Renovation</title>\n";
print $fh "</head>\n";
print $fh "<body bgcolor=white>\n";
print $fh "<h1>Basement Ceiling Materials</h1>\n";
# get files from Desktop/images/
my $path = '/home/dan/Desktop/upload/';
my @files = <$path*>;
# get ls from remote image directory
$ftp->cwd('/images/') or die "cwd failed $@\n";
my @list = $ftp->ls();
# main control
for my $name (@files) {
print "name is $name\n";
my ($ext) = $name =~ /([^.]*)$/;
print "ext is $ext\n";
@matching = map /image_(\d+)\.$ext$/, @list;
print "matching is @matching\n";
push( @matching, 1 );
@matching = sort { $a <=> $b } @matching;
$winner = pop @matching;
my $newnum = $winner + 1;
my $new_file2 = "image_$newnum.$ext";
print "newfile is $new_file2\n";
$ftp->put( $name, $new_file2 ) or die "put failed $!\n";
push( @list, $new_file2 );
# unlink($name);
print $fh "<img src=\"/images/$new_file2\"/>\n\n";
print $fh "<p>caption for $new_file2 <\/p>\n";
}
my $sourcefile = 'ceiling5.pl';
open( my $gh, '<', $sourcefile )
or die("Can't open $sourcefile for writing: $!");
while (<$gh>){
chomp;
print $fh '<p>'. $_ . '</p>';
}
close $gh;
close $fh;
$ftp->cdup() or die "cdup failed $@\n";
$ftp->put($html_file) or die "put failed $@\n";
my @r = $ftp->ls();
print "@r\n";
$
It's there and kind of interesting how it got munged:
http://www.merrillpjensen.com/jdwrt__2.html
>
>> What I tried to do was to write a source file to output. Does argv
>> contain the prog's name?
>
> No. The program's name is in $0, and it may or may not be an absolute
> path depending on how it was invoked.
I'll try that next time.
>
>> How would I switch _abc_ for a random composition of friendly letters in
>> a character class?
>
> What do you mean?
A subroutine to prepend 5 nice random letters, using the character class
we talked about 3 weeks ago. I still don't get how to call a subroutine
properly, unless it's with &.
Btw, the images aren't mine. I didn't make them but am making a free
use of them. Some are offensive. Some have adult content. I am not a
pornographer. Most are interesting.
--
Cal
------------------------------
Date: Fri, 27 Jul 2012 16:53:06 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Linux, IO::Socket::INET and recv'ing broadcasted UDP
Message-Id: <slrnk15aqj.gm3.hjp-usenet2@hrunkner.hjp.at>
On 2012-07-26 17:03, mkparam@gmail.com <mkparam@gmail.com> wrote:
> All
>
> I know this is a pretty old thread, but looks like i hit the exact
> same problem this week while trying to use DHCP::Packet.
[...]
> When i use a script like this one, i can see the DHCPDISCOVER is sent
> properly as it reaches the server and DHCPOFFER is also being made by
> the server as per the logs ; but my script does not pick up the packet
> for some reasons which i am unable to understand.
>
> --script --
[...]
> $handle = IO::Socket::INET->new(Proto => 'udp',
> Broadcast => 1,
> PeerPort => 67,
> LocalPort => 68,
> LocalAddr => '192.168.1.3',
> PeerAddr => '255.255.255.255')
> || die "Socket creation error: $@\n"; # yes, it uses $@ here
[...]
> 17:41:09.706661 IP (tos 0x0, ttl 64, id 38874, offset 0, flags [DF], proto: UDP (17), length: 328) 192.168.1.3.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:56:98:23:8d (oui Unknown), length: 300, xid:0x12345678, flags: [none] (0x0000)
> Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
> 17:41:09.706840 IP (tos 0x10, ttl 16, id 0, offset 0, flags [none], proto: UDP (17), length: 328) 192.168.1.2.bootps > 192.168.1.50.bootpc: BOOTP/DHCP,
> Reply, length: 300, xid:0x12345678, flags: [none] (0x0000)
> Your IP: 192.168.1.50
> Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
I guess this is the reason: You are sending the request from 192.168.1.3
and have bound the socket to this address. But the answer is sent to
192.168.1.50, so you won't receive it. Binding to 0.0.0.0 may help, but
I doubt it: If you currently don't have the address 192.168.1.50, I
think the kernel is supposed to discard the packet. You may have to use
a raw socket.
hp
--
_ | Peter J. Holzer | Deprecating human carelessness and
|_|_) | Sysadmin WSR | ignorance has no successful track record.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Bill Code on asrg@irtf.org
------------------------------
Date: Fri, 27 Jul 2012 17:17:47 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Linux, IO::Socket::INET and recv'ing broadcasted UDP
Message-Id: <birae9-bcq1.ln1@anubis.morrow.me.uk>
Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2012-07-26 17:03, mkparam@gmail.com <mkparam@gmail.com> wrote:
> >
> > I know this is a pretty old thread, but looks like i hit the exact
> > same problem this week while trying to use DHCP::Packet.
> [...]
> > When i use a script like this one, i can see the DHCPDISCOVER is sent
> > properly as it reaches the server and DHCPOFFER is also being made by
> > the server as per the logs ; but my script does not pick up the packet
> > for some reasons which i am unable to understand.
> >
> > --script --
> [...]
> > $handle = IO::Socket::INET->new(Proto => 'udp',
> > Broadcast => 1,
> > PeerPort => 67,
> > LocalPort => 68,
> > LocalAddr => '192.168.1.3',
> > PeerAddr => '255.255.255.255')
> > || die "Socket creation error: $@\n"; # yes, it uses $@ here
> [...]
> > 17:41:09.706661 IP (tos 0x0, ttl 64, id 38874, offset 0, flags [DF],
> proto: UDP (17), length: 328) 192.168.1.3.bootpc >
> 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:56:98:23:8d (oui
> Unknown), length: 300, xid:0x12345678, flags: [none] (0x0000)
> > Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
> > 17:41:09.706840 IP (tos 0x10, ttl 16, id 0, offset 0, flags [none],
> proto: UDP (17), length: 328) 192.168.1.2.bootps > 192.168.1.50.bootpc:
> BOOTP/DHCP,
> > Reply, length: 300, xid:0x12345678, flags: [none] (0x0000)
> > Your IP: 192.168.1.50
> > Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
>
> I guess this is the reason: You are sending the request from 192.168.1.3
> and have bound the socket to this address. But the answer is sent to
> 192.168.1.50, so you won't receive it. Binding to 0.0.0.0 may help, but
> I doubt it: If you currently don't have the address 192.168.1.50, I
> think the kernel is supposed to discard the packet. You may have to use
> a raw socket.
You will also need to put the interface in promiscuous mode, or the
packet will be thrown away by the hardware or the low-level driver
before the sockets code sees it. Examining the code of something like
dhclient may give you some clues about how to do this sort of thing
portably.
Ben
------------------------------
Date: Fri, 27 Jul 2012 16:38:27 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Regx explanation please
Message-Id: <slrnk159v3.gm3.hjp-usenet2@hrunkner.hjp.at>
On 2012-07-26 13:17, Dave Saville <dave@invalid.invalid> wrote:
> 2) How does that regex actually work? I get the followed by three
> digits bit - but its the -?\d+ bit I don't understand. And my camel
> book does not mention -? Nor does perlre.
The "-" isn't mentioned because it doesn't have any special meaning. It's
just a literal "-". Perlre does explain "?". I'm fairly sure the camel
book does, too.
hp
--
_ | Peter J. Holzer | Deprecating human carelessness and
|_|_) | Sysadmin WSR | ignorance has no successful track record.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Bill Code on asrg@irtf.org
------------------------------
Date: Fri, 27 Jul 2012 15:48:36 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: Regx explanation please
Message-Id: <fV45K0OBJxbE-pn2-Y6sdFdIF33Do@localhost>
On Fri, 27 Jul 2012 14:38:27 UTC, "Peter J. Holzer"
<hjp-usenet2@hjp.at> wrote:
> On 2012-07-26 13:17, Dave Saville <dave@invalid.invalid> wrote:
> > 2) How does that regex actually work? I get the followed by three
> > digits bit - but its the -?\d+ bit I don't understand. And my camel
> > book does not mention -? Nor does perlre.
>
> The "-" isn't mentioned because it doesn't have any special meaning. It's
> just a literal "-". Perlre does explain "?". I'm fairly sure the camel
> book does, too.
But of course I was looking for both characters together :-( I think I
have got so used to ?'s near the front of a regex doing something
strange that it never occurred to me that is was actually "none or 1
-" :-)
--
Regards
Dave Saville
------------------------------
Date: Fri, 27 Jul 2012 17:15:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Regx explanation please
Message-Id: <ierae9-bcq1.ln1@anubis.morrow.me.uk>
Quoth "Dave Saville" <dave@invalid.invalid>:
> On Fri, 27 Jul 2012 14:38:27 UTC, "Peter J. Holzer"
> <hjp-usenet2@hjp.at> wrote:
>
> > On 2012-07-26 13:17, Dave Saville <dave@invalid.invalid> wrote:
> > > 2) How does that regex actually work? I get the followed by three
> > > digits bit - but its the -?\d+ bit I don't understand. And my camel
> > > book does not mention -? Nor does perlre.
> >
> > The "-" isn't mentioned because it doesn't have any special meaning. It's
> > just a literal "-". Perlre does explain "?". I'm fairly sure the camel
> > book does, too.
>
> But of course I was looking for both characters together :-( I think I
> have got so used to ?'s near the front of a regex doing something
> strange that it never occurred to me that is was actually "none or 1
> -" :-)
The only cases where ? means something other than 'one-or-more' are
inside a character class, as a 'non-greedy' suffix on another
quantifier, and as part of a (?...) extended pattern. Being 'at the
beginning' is not important.
The same applies to the other quantifiers * and +: 5.10 adds + as a
'possessive' qualification to a quantifier (so /.*+/ is equivalent to
/(?>.*)/), and (*...) groups as control verbs.
Ben
------------------------------
Date: Sat, 28 Jul 2012 15:17:52 +0300
From: "George Mpouras" <nospam.gravitalsun.antispam@hotmail.com.nospam>
Subject: web service
Message-Id: <jv0l9i$kr9$1@news.ntua.gr>
Boss asked for a "web service" that must do some work at server and give
back some "REST" data over "JSON"
Please help , I search for modules and info at cpan/google but I get more
confused.
Give me some guidelines of what to to.
------------------------------
Date: Sat, 28 Jul 2012 14:06:01 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: web service
Message-Id: <874nosox1i.fsf@sapphire.mobileactivedefense.com>
"George Mpouras" <nospam.gravitalsun.antispam@hotmail.com.nospam>
writes:
> Boss asked for a "web service" that must do some work at server and
> give back some "REST" data over "JSON"
> Please help , I search for modules and info at cpan/google but I get
> more confused.
> Give me some guidelines of what to to.
It is claimed that 'REST' means 'representational state transfer' and
that it is not a backronym someone chose because of its desired
connotation. The term had its origin in the remarkable fact that, at
least at one English university, inventing a new terminology for
describing something someone else did, was good enough for a degree in
'elaborate idle babbling about abstract concepts invented for this
purpose' aka 'theoretical computer science'. Practically, it means
"using HTTP".
JSON means 'Javascript object notation', yet another system for
turning structure data into text, reportedly using or based on the
Javascript syntax for specifying such objects.
'Web services' usually (AFAIK) refers to a message format
specification describing the content of certain HTTP requests and
replies. The acronym WSDL (probably, 'web service definition
language') might be of use for getting at the details.
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3746
***************************************