[32482] in Perl-Users-Digest
Perl-Users Digest, Issue: 3747 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 31 11:09:22 2012
Date: Tue, 31 Jul 2012 08:09:07 -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 Tue, 31 Jul 2012 Volume: 11 Number: 3747
Today's topics:
"is-numeric" check? <oneingray@gmail.com>
Re: "is-numeric" check? <NoSpamPleaseButThisIsValid3@gmx.net>
Re: "is-numeric" check? <oneingray@gmail.com>
Re: "is-numeric" check? <jurgenex@hotmail.com>
Re: "is-numeric" check? <ben@morrow.me.uk>
Re: "is-numeric" check? <oneingray@gmail.com>
Re: "is-numeric" check? <oneingray@gmail.com>
Re: "is-numeric" check? <rvtol+usenet@xs4all.nl>
Re: "is-numeric" check? <oneingray@gmail.com>
Re: "is-numeric" check? <rvtol+usenet@xs4all.nl>
Re: "is-numeric" check? <rweikusat@mssgmbh.com>
Re: "is-numeric" check? <ben@morrow.me.uk>
a regex for removing a password in a source listing <cal@example.invalid>
Re: a regex for removing a password in a source listing <NoSpamPleaseButThisIsValid3@gmx.net>
Re: a regex for removing a password in a source listing <ben@morrow.me.uk>
Re: I killed my own source. <ben@morrow.me.uk>
Re: Linux, IO::Socket::INET and recv'ing broadcasted UD mkparam@gmail.com
Re: Linux, IO::Socket::INET and recv'ing broadcasted UD <ben@morrow.me.uk>
Re: web service <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 29 Jul 2012 15:16:17 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: "is-numeric" check?
Message-Id: <86boizugmm.fsf@gray.siamics.net>
Is there a simple way to check if a value is numeric in Perl?
FWIW, (($x + 0) eq $x) doesn't fit, as it returns false should
$x contain any leading zeros or whitespace.
Apparently, there /is/ such a check in Perl, but is there a way
to call it explicitly?
TIA.
$ perl -we 'print ("non-numeric" + 0, "\n");'
Argument "non-numeric" isn't numeric in addition (+) at -e line 1.
0
$
--
FSF associate member #7257 http://sf-day.org/
------------------------------
Date: Sun, 29 Jul 2012 10:41:20 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: "is-numeric" check?
Message-Id: <5014f730$0$6580$9b4e6d93@newsspool3.arcor-online.net>
Am 29.07.2012 10:16, schrieb Ivan Shmakov:
> Is there a simple way to check if a value is numeric in Perl?
Maybe you want:
use Scalar::Util qw(looks_like_number);
- Wolf
------------------------------
Date: Sun, 29 Jul 2012 16:19:04 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: "is-numeric" check?
Message-Id: <86394avsaf.fsf@gray.siamics.net>
>>>>> Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net> writes:
>>>>> Am 29.07.2012 10:16, schrieb Ivan Shmakov:
>> Is there a simple way to check if a value is numeric in Perl?
> Maybe you want:
> use Scalar::Util qw(looks_like_number);
Indeed, and it even seems to differentiate between integers,
floats and "specials" (which is what I need), like:
$ perl -we 'use Scalar::Util qw (looks_like_number);
foreach my $v (" 12", "abc", " 03", "4.5", ".67", "NaN") {
printf ("%3d %s\n", looks_like_number ($v), $v);
};'
1 12
0 abc
1 03
5 4.5
5 .67
36 NaN
$
Unfortunately, perlapi(3perl) [1] doesn't seem to describe the
exact meaning of these distinct values, so I guess I shouldn't
rely on that.
[1] http://perldoc.perl.org/perlapi.html#looks_like_number
--
FSF associate member #7257 http://sf-day.org/
------------------------------
Date: Sun, 29 Jul 2012 03:46:44 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: "is-numeric" check?
Message-Id: <d05a18tuuqeiudo29qqr42kbvs42qo7s1d@4ax.com>
Ivan Shmakov <oneingray@gmail.com> wrote:
> Is there a simple way to check if a value is numeric in Perl?
At some time this Question was Asked Frequently. Please see
"perldoc -q number":
"How do I determine whether a scalar is a
number/whole/integer/float?"
jue
------------------------------
Date: Sun, 29 Jul 2012 14:21:06 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: "is-numeric" check?
Message-Id: <2vpfe9-4em.ln1@anubis.morrow.me.uk>
Quoth Ivan Shmakov <oneingray@gmail.com>:
>
> Indeed, and it even seems to differentiate between integers,
> floats and "specials" (which is what I need), like:
>
> $ perl -we 'use Scalar::Util qw (looks_like_number);
> foreach my $v (" 12", "abc", " 03", "4.5", ".67", "NaN") {
> printf ("%3d %s\n", looks_like_number ($v), $v);
> };'
> 1 12
> 0 abc
> 1 03
> 5 4.5
> 5 .67
> 36 NaN
> $
>
> Unfortunately, perlapi(3perl) [1] doesn't seem to describe the
> exact meaning of these distinct values, so I guess I shouldn't
> rely on that.
They are documented under grok_number, which is called by lln for
scalars which are currently strings. This isn't reliable, though,
because scalars which are currently numbers will return something
entirely different:
perl -MScalar::Util=looks_like_number
-E'say looks_like_number $_ for
qw/abc 12 5.5 NaN/, 12, 5.5, 0+"NaN"'
0
1
5
36
4352
8704
8704
(Scalar::Util really ought to smash its return value to boolean.)
Ben
------------------------------
Date: Mon, 30 Jul 2012 12:37:33 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: "is-numeric" check?
Message-Id: <867gtlu7vm.fsf@gray.siamics.net>
>>>>> Ben Morrow <ben@morrow.me.uk> writes:
>>>>> Quoth Ivan Shmakov <oneingray@gmail.com>:
>> Indeed, and it even seems to differentiate between integers, floats
>> and "specials" (which is what I need), like:
[...]
>> Unfortunately, perlapi(3perl) [1] doesn't seem to describe the exact
>> meaning of these distinct values, so I guess I shouldn't rely on
>> that.
> They are documented under grok_number, which is called by lln for
> scalars which are currently strings. This isn't reliable, though,
> because scalars which are currently numbers will return something
> entirely different:
[...]
> (Scalar::Util really ought to smash its return value to boolean.)
ACK, thanks. I've decided that I don't actually need to
distinguish integers from non-integers, and for now ended up
with the following bit of code:
sub number_or {
foreach my $v (@_) {
## .
return $v
if (looks_like_number ($v));
}
## .
undef;
}
## FIXME: should signal an error if FOO exists, non-empty and non-number
my $foo
= number_or ($ENV{"FOO"},
$ENV{"FOO_COMPAT"},
$foo_default);
--
FSF associate member #7257 http://sf-day.org/
------------------------------
Date: Mon, 30 Jul 2012 12:57:20 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: "is-numeric" check?
Message-Id: <861ujtu6yn.fsf@gray.siamics.net>
>>>>> Jürgen Exner <jurgenex@hotmail.com> writes:
>>>>> Ivan Shmakov <oneingray@gmail.com> wrote:
BTW, the From: of the article I'm replying to contains unencoded
(as per RFC 2047) non-ASCII data, which is explicitly prohibited
by the recent revision of the Netnews article format (RFC 5536,
section 2.2.)
The interoperability is thus non-warranted.
(In particular, I'm planning to work on a "NNTP server"
implementation next year, and it's likely that it will reject
messages with non-ASCII headers outright.)
>> Is there a simple way to check if a value is numeric in Perl?
> At some time this Question was Asked Frequently. Please see "perldoc
> -q number":
> "How do I determine whether a scalar is a
> number/whole/integer/float?"
ACK, thanks. It mentions looks_like_number, too, but also
POSIX::strtod, POSIX::strtol (which are somewhat non-portable,
AIUI); and pure-Perl String::Scanf and a solution using "given",
both based on Perl regular expressions, which I'd like to avoid.
(JFTR: it's also at [1].)
[1] http://perldoc.perl.org/perlfaq4.html
--
FSF associate member #7257 http://sf-day.org/
------------------------------
Date: Mon, 30 Jul 2012 11:22:39 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: "is-numeric" check?
Message-Id: <5016525f$0$6890$e4fe514c@news2.news.xs4all.nl>
On 2012-07-29 10:16, Ivan Shmakov wrote:
> Is there a simple way to check if a value is numeric in Perl?
No. Why do you think that you need it?
Perl is a strongly typed language. The type is not in the values, as it
is in many other languages, but in the operators.
--
Ruud
------------------------------
Date: Mon, 30 Jul 2012 17:06:06 +0700
From: Ivan Shmakov <oneingray@gmail.com>
Subject: Re: "is-numeric" check?
Message-Id: <86vch5sgvl.fsf@gray.siamics.net>
>>>>> Ruud <rvtol+usenet@xs4all.nl> writes:
>>>>> On 2012-07-29 10:16, Ivan Shmakov wrote:
>> Is there a simple way to check if a value is numeric in Perl?
> No. Why do you think that you need it?
My program receives a crucial piece of information via its
command line, and I'd like it to fail with a clear error message
should a non-number be passed, instead of silently (or with a
warning) interpreting it as zero.
> Perl is a strongly typed language.
I guess that my $x = "x" + 1; should then die at once.
> The type is not in the values, as it is in many other languages, but
> in the operators.
--
FSF associate member #7257 http://sf-day.org/
------------------------------
Date: Mon, 30 Jul 2012 14:24:08 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: "is-numeric" check?
Message-Id: <50167ce8$0$6983$e4fe514c@news2.news.xs4all.nl>
On 2012-07-30 12:06, Ivan Shmakov wrote:
> Ruud <rvtol+usenet@xs4all.nl> writes:
>> On 2012-07-29 10:16, Ivan Shmakov wrote:
>>> Is there a simple way to check if a value is numeric in Perl?
>>
>> No. Why do you think that you need it?
>
> My program receives a crucial piece of information via its
> command line, and I'd like it to fail with a clear error message
> should a non-number be passed, instead of silently (or with a
> warning) interpreting it as zero.
So you need to validate user input. For that you need to use a parser.
How do you define 'numeric'? Does 1_000_000 == 1000000?
>> Perl is a strongly typed language.
>
> I guess that my $x = "x" + 1; should then die at once.
perl -Mstrict -wle'
#local $SIG{"__WARN__"}= sub { die @_ };
my $x= "x" + 1;
print $x;
'
If you need it to die on warnings, uncomment that SIG line.
--
Ruud
------------------------------
Date: Mon, 30 Jul 2012 14:18:05 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: "is-numeric" check?
Message-Id: <87vch54cc2.fsf@sapphire.mobileactivedefense.com>
"Dr.Ruud" <rvtol+usenet@xs4all.nl> writes:
> On 2012-07-30 12:06, Ivan Shmakov wrote:
[...]
>>> Perl is a strongly typed language.
>>
>> I guess that my $x = "x" + 1; should then die at once.
>
> perl -Mstrict -wle'
> #local $SIG{"__WARN__"}= sub { die @_ };
> my $x= "x" + 1;
> print $x;
> '
>
> If you need it to die on warnings, uncomment that SIG line.
A strongly-typed language would be one where no automatic conversions
are performed, especially not very likely wrong ones like converting
"x" to 0. But by default, Perl doesn't even warn about this
conversion, this has to be enabled explicitly and that explicit code
needs to be written in order to turn this optional warning into a
fatal runtime error is also the opposited of 'strongly typed'.
------------------------------
Date: Mon, 30 Jul 2012 22:59:57 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: "is-numeric" check?
Message-Id: <tncje9-kdh1.ln1@anubis.morrow.me.uk>
Quoth "Dr.Ruud" <rvtol+usenet@xs4all.nl>:
>
> perl -Mstrict -wle'
> #local $SIG{"__WARN__"}= sub { die @_ };
> my $x= "x" + 1;
> print $x;
> '
>
> If you need it to die on warnings, uncomment that SIG line.
A better alternative would be
use warnings FATAL => "numeric";
Ben
------------------------------
Date: Mon, 30 Jul 2012 15:26:02 -0600
From: Cal Dershowitz <cal@example.invalid>
Subject: a regex for removing a password in a source listing
Message-Id: <OoudnbIFAJF2ZovNnZ2dnUVZ_smdnZ2d@supernews.com>
On 07/29/2012 07:10 AM, Ben Morrow wrote:
>
> Quoth Cal Dershowitz<cal@example.invalid>:
>> On 07/28/2012 05:28 AM, Ben Morrow wrote:
[snipped, re-ordered, title changed]
>> I still don't get how to call a subroutine
>> properly, unless it's with&.
>
> sub foo { ... }
>
> foo(...);
>
> The brackets are required unless you declare the sub before using it. If
> you want to be able to leave them out you can use one of
>
> sub foo;
> use subs qw/foo/;
>
> to predeclare subs at the top of the file. (This is not entirely unlike
> C prototypes, except for the 'prototype' part.)
Ok, I think programmers of a certain age are simply averse to pushing
the limits. Perl is already so flexible compared to what we had 20
years ago.
> I'll try once more. Please explain, *IN ENGLISH*, what you are trying to
> do and what is not working. Dumping a whole lot of logs and code is not
> an alternative to an explanation.
$ cat quine2.pl
#!/usr/bin/perl -w
use strict;
use 5.010;
my $html_file = "/home/dan/Desktop/previousdec2011/iypjx_2.html";
# print "html file is $html_file\n";
open( my $gh, '+<', $html_file )
or die("Can't open $html_file for writing: $!");
while (<$gh>) {
chomp;
# this is not working
# this may look obvious, but it's not
# s/my \$password = '.*';/my \$password = 'redacted';/;
# s/my \$username = '.*';/my \$username = 'redacted';/;
if (/\$password/) {
print "matched\n";
$_ =~ s/'.*'/'redacted'/;
}
}
close $gh;
$
When I run this on these ftp upload files that have my password in it, I
get "matched" 3 times like I would suspect, but I get no effective
substitution. Tried several things now. As you see it, there's
nothing that writes the line to the file. When I add my best guess, I
get very exotic output, which I would show but for the insistence that I
not do so.
Hasn't anyone else used a a script to erase his passwords so that he can
share his source without torpedoing his security?
--
Cal
--
Cal
------------------------------
Date: Mon, 30 Jul 2012 23:46:53 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: a regex for removing a password in a source listing
Message-Id: <501700cd$0$6565$9b4e6d93@newsspool4.arcor-online.net>
Am 30.07.2012 23:26, schrieb Cal Dershowitz:
> On 07/29/2012 07:10 AM, Ben Morrow wrote:
>> The brackets are required unless you declare the sub before using it. If
>> you want to be able to leave them out you can use one of
>>
>> sub foo;
>> use subs qw/foo/;
>>
>> to predeclare subs at the top of the file. (This is not entirely unlike
>> C prototypes, except for the 'prototype' part.)
>
> Ok, I think programmers of a certain age are simply averse to pushing
> the limits. Perl is already so flexible compared to what we had 20
> years ago.
Sorry, I don't understand - what does it have to do with pushing
something to the limits? Usually you do NOT need to predeclare a sub.
perl -wE'foo(); sub foo{ say q(I am foo) }'
> $ cat quine2.pl
> #!/usr/bin/perl -w
> use strict;
> use 5.010;
>
> my $html_file = "/home/dan/Desktop/previousdec2011/iypjx_2.html";
>
> # print "html file is $html_file\n";
>
> open( my $gh, '+<', $html_file )
> or die("Can't open $html_file for writing: $!");
ah, you open the file in rw mode.
> while (<$gh>) {
This is while (defined($_ = <$gh>)), i.e. you now have a new value in $_
corresponding to a line. This is a copy! So modifying $_ doesn't do
anything to the file!
> chomp;
>
> # this is not working
> # this may look obvious, but it's not
> # s/my \$password = '.*';/my \$password = 'redacted';/;
> # s/my \$username = '.*';/my \$username = 'redacted';/;
>
> if (/\$password/) {
> print "matched\n";
> $_ =~ s/'.*'/'redacted'/;
Are you sure about this replacement? Replacing anyhing between the first
' of the line and the last ' of the line?
> }
>
> }
> close $gh;
> $
>
> When I run this on these ftp upload files that have my password in it, I
> get "matched" 3 times like I would suspect, but I get no effective
> substitution. Tried several things now. As you see it, there's
> nothing that writes the line to the file. When I add my best guess, I
> get very exotic output, which I would show but for the insistence that I
> not do so.
You are not writing to the file. So the replacement doesn't have any effect.
> Hasn't anyone else used a a script to erase his passwords so that he can
> share his source without torpedoing his security?
What about perl's in-place edit? See perldoc perlrun!
Just run
perl -pi -e 's/password/redacted/g' /path/to/iypjx_2.html
or maybe
perl -pi -e "s/'password'/'redacted'/g" /path/to/iypjx_2.html
if you only want to replace the password if it is between single quotes.
(you can also run perl -pi.bak -e ... to get a backup file with .bak
extension)
- Wolf
------------------------------
Date: Tue, 31 Jul 2012 00:00:50 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: a regex for removing a password in a source listing
Message-Id: <2agje9-s3i1.ln1@anubis.morrow.me.uk>
Quoth Cal Dershowitz <cal@example.invalid>:
> On 07/29/2012 07:10 AM, Ben Morrow wrote:
>
> > I'll try once more. Please explain, *IN ENGLISH*, what you are trying to
> > do and what is not working. Dumping a whole lot of logs and code is not
> > an alternative to an explanation.
>
> $ cat quine2.pl
You have omitted the part where you explain in English what you are
trying to do. It may be possible to divine from your code, but that is
not the same as an explanation. An explanation looks something like
I am trying to open a Perl source file and copy it to another file
with all the passwords removed.
The code you posted before was doing a great number of things, and it
wasn't at all clear which of those things wasn't working.
> #!/usr/bin/perl -w
> use strict;
> use 5.010;
>
> my $html_file = "/home/dan/Desktop/previousdec2011/iypjx_2.html";
>
> # print "html file is $html_file\n";
>
> open( my $gh, '+<', $html_file )
> or die("Can't open $html_file for writing: $!");
> while (<$gh>) {
> chomp;
>
> # this is not working
> # this may look obvious, but it's not
> # s/my \$password = '.*';/my \$password = 'redacted';/;
> # s/my \$username = '.*';/my \$username = 'redacted';/;
>
> if (/\$password/) {
> print "matched\n";
> $_ =~ s/'.*'/'redacted'/;
> }
>
> }
> close $gh;
> $
>
> When I run this on these ftp upload files that have my password in it, I
> get "matched" 3 times like I would suspect, but I get no effective
> substitution. Tried several things now. As you see it, there's
> nothing that writes the line to the file. When I add my best guess, I
> get very exotic output, which I would show but for the insistence that I
> not do so.
You could at least show us what your best guess was, since I believe the
substitution is working perfectly. You are, I hope, aware that
attempting to overwrite a file while you are reading it is likely to
produce confusing results? The normal procedure is to write a new file
(you can create a secure temporary file with File::Temp) and rename it
over the top.
This
#!/usr/bin/perl
use warnings;
use strict;
while (<DATA>) {
if (/\$password/) {
s/'.*'/'redacted'/;
}
print;
}
__DATA__
use warnings;
use strict;
use Net::FTP;
my $password = 'foo';
my $F = Net::FTP->new(...);
works for me: that is, it prints the contents of the DATA section with
the password assignment replaced.
> Hasn't anyone else used a a script to erase his passwords so that he can
> share his source without torpedoing his security?
It's not a common thing to want to do, because it's generally a bad idea
to put passwords directly in the script file in the first place. The
best thing to do, if you need a password, is to prompt for it (you can
use Term::ReadKey to prompt without echoing); if you must keep it in a
file, make it a separate config file so the script can be shared with
others/checked into a VCS/whatever without revealing your passwords.
Ben
------------------------------
Date: Sun, 29 Jul 2012 14:10:31 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: I killed my own source.
Message-Id: <7bpfe9-4em.ln1@anubis.morrow.me.uk>
Quoth Cal Dershowitz <cal@example.invalid>:
> 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.
I'll try once more. Please explain, *IN ENGLISH*, what you are trying to
do and what is not working. Dumping a whole lot of logs and code is not
an alternative to an explanation.
> >> 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 don't remember that discussion in detail, but picking 5 random letters
from a list isn't hard. perldoc -f rand.
> I still don't get how to call a subroutine
> properly, unless it's with &.
sub foo { ... }
foo(...);
The brackets are required unless you declare the sub before using it. If
you want to be able to leave them out you can use one of
sub foo;
use subs qw/foo/;
to predeclare subs at the top of the file. (This is not entirely unlike
C prototypes, except for the 'prototype' part.)
> 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.
FSVO...
Ben
------------------------------
Date: Tue, 31 Jul 2012 05:07:40 -0700 (PDT)
From: mkparam@gmail.com
Subject: Re: Linux, IO::Socket::INET and recv'ing broadcasted UDP
Message-Id: <5e4f54f5-38e5-4df4-aba4-d75b0daa89b8@googlegroups.com>
Thank you Ben and Peter for your replies. Now my comments specific to your =
ideas ..
#1 I did check the promiscuous mode before replying and it was indeed open =
and i got it open through the 'ip link' for the interface too, but those di=
d not help. Since I was able to see the packets floating in the tcpdump at =
the server and client i believed that the issue is with the script only and=
indeed it was.
#2 when i set the 'PeerAddr' to 0.0.0.0, it did not help so i reverted back=
to my client eth1 IP.
#3 I changed the PeerPort and LocalPort to '67'
#4 I checked the dhclient and it got the ip from my server so if that can =
work and my script can't , proves a point that the script has an issue. Lat=
er i played around in the script and got it working..=20
Now my script looks like this=20
....
$handle =3D IO::Socket::INET->new(Proto =3D> 'udp',
Broadcast =3D> 1,
PeerPort =3D> 67,
LocalPort =3D> 67,
PeerAddr =3D> '192.168.1.2')
|| die "Socket creation error: $@\n"; # yes, it uses $@ here
# create DHCP Packet DISCOVER
$discover =3D Net::DHCP::Packet->new(
op=3D> BOOTREQUEST(),
Htype =3D> '0',
Hlen =3D> '6',
Ciaddr =3D> '0',
Chaddr =3D> $MAC,
Giaddr =3D> $handle -> sockhost(),
Xid =3D> int(rand(0xFFFFFFFF)),
DHO_DHCP_MESSAGE_TYPE() =3D> DHCPDISCOVER(),
);
...
Now, I receive the IP's from the client and i can read the packet as i want=
ed , works GREAT !!=20
But, a new challenge, I noticed that every time i send the 'DHCPREQUEST' , =
my client gets a new IP though i pass on a hard-coded mac-address(MAC1 as a=
n argument to pass on with different MACs for my try's) in the script. Serv=
er reads this MAC but rather than throwing an IP that was already given (pe=
r leases, its not expired) it gives a new IP. Is this expected ?=20
Now questions ..
1. Are there any settings in the dhcpd.conf that has to explicitly say to l=
ook for leases before giving new Ip's?
2. How do i determine if the server has a valid lease for the mac i am send=
ing before i can initiate a DHCPREQUEST ? ( Since i m scripting i want to m=
ake sure that for a particular mac , server gives the IP as per the lease i=
f it is not expired and if it is let it renew rather than giving a new vali=
d lease with a different IP. makes sense ? ) ; I came across 'DHCPLEASEQUER=
Y' and realized (may be) it is not supported in 3.0.5 dhcpd version i am us=
ing ? I have told the support to upgrade to dhcp3.1 on RHEL5.=20
My requirement is like : <script> MAC which has to talk to my server , gets=
a IP if it has not having a valid lease . if new, get the IP and mark a le=
ase. I am OK to check if it has a valid lease before placing a DHCPREQUEST =
but just not sure how i can do(what type of DHO_DHCP_MESSAGE_TYPE does that=
? )
Param
------------------------------
Date: Tue, 31 Jul 2012 15:18:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Linux, IO::Socket::INET and recv'ing broadcasted UDP
Message-Id: <t16le9-9rs1.ln1@anubis.morrow.me.uk>
Quoth mkparam@gmail.com:
>
> But, a new challenge, I noticed that every time i send the 'DHCPREQUEST'
> , my client gets a new IP though i pass on a hard-coded mac-address(MAC1
> as an argument to pass on with different MACs for my try's) in the
> script. Server reads this MAC but rather than throwing an IP that was
> already given (per leases, its not expired) it gives a new IP. Is this
> expected ?
I don't know; it probably depends on your DHCP server configuration. For
one thing, it isn't necessarily certain that a client with the same MAC
address is the 'same' client from a DHCP perspective.
> Now questions ..
>
> 1. Are there any settings in the dhcpd.conf that has to explicitly say
> to look for leases before giving new Ip's?
I believe the usual practice is for the client to remember its own
leases, and if it thinks it still has a valid lease to start with
DHCPREQUEST rather than DHCPDISCOVER. Certainly that's how all the DHCP
clients I've seen work.
Ben
------------------------------
Date: Mon, 30 Jul 2012 14:58:49 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: web service
Message-Id: <5016e779$0$75673$815e3792@news.qwest.net>
On 07/28/12 07:17, George Mpouras wrote:
>
> 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.
http://en.wikipedia.org/wiki/Representational_state_transfer
http://rest.elkstein.org/2008/02
Helpful Perl modules: SOAP::Lite, LWP, JSON
------------------------------
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 3747
***************************************