[16887] in Perl-Users-Digest
Perl-Users Digest, Issue: 4299 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 12 14:15:34 2000
Date: Tue, 12 Sep 2000 11:15:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968782522-v9-i4299@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Sep 2000 Volume: 9 Number: 4299
Today's topics:
Please help me with my shotty code... <epost1@my-deja.com>
Re: Please help me with my shotty code... <anders@wall.alweb.dk>
Re: Qualifications for new Perl programmer????? <smerr612@mailandnews.com>
Re: Qualifications for new Perl programmer????? <iltzu@sci.invalid>
Re: Resolving IP's Q: Does this IP actually exist? <christopher_j@uswest.net>
Re: Resolving IP's Q: Does this IP actually exist? (David Wall)
Re: Script To automate ftp uploading <sholden@holdenweb.com>
Re: Script To automate ftp uploading <royterry@earthlink.net>
Re: use strict: why? (Anno Siegel)
Re: using filehandles in strict mode nobull@mail.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Sep 2000 17:12:53 GMT
From: Ethan Post <epost1@my-deja.com>
Subject: Please help me with my shotty code...
Message-Id: <8plo5u$u0r$1@nnrp1.deja.com>
I have written an interface between Oracle and MRTG (www.mrtg.org).
One of the components is a Perl script. The role of the script is to
search a flat file of key value pairs, find the key and return the
value plus a few other lines. The script is called from the MRTG
configuration file.
The problem is that when running on Windows 98 with ActiveState's Perl
I get the error message:
Can't fork to start 'C:\perl\bin\perl C:\mrtg\run\mrtg_read.pl
C:\_data\SFSK_HQA
SDEV_oracle8.gum ora8_tablespace_usedspc_users': Bad file descriptor
Could not get any data from external command 'C:\perl\bin\perl
C:\mrtg\run\mrtg_
read.pl C:\_data\SFSK_HQASDEV_oracle8.gum ora8_tablespace_usedspc_users'
Maybe the external command did not even start. (Bad file descriptor)
This occurs when there are too many "targets" in the file. This error
does not
occur on NT with the same version of MRTG. I suspect I'm bumping up
against some sort of limit here because if I have only 1 or 2 targets
it works fine. Each target means another instance of Perl that need
gets fired up to search the file.
Anyway the code for the actual Perl script is below, if anyone has a
better method for searching a file for a key value pair in a flat file
let me know.
**Don't Laugh**
open(METRIC, @ARGV[0]);
while (<METRIC>) {
($ival, $utim, $nam) = split(/\|/);
$nam == chop $nam;
if ($nam eq @ARGV[1]) {
print($ival,"\r\n","0","\r\n",$utim,"\r\n", $nam,"\r\n");
}
}
close(METRIC);
**Stop Laughing**
-Ethan
http://www.freetechnicaltraining.com
http://www.gnumetrics.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Sep 2000 17:36:02 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Please help me with my shotty code...
Message-Id: <6Qtv5.700$Oh1.8405@news000.worldonline.dk>
Ethan Post wrote:
> I have written an interface between Oracle and MRTG (www.mrtg.org).
> One of the components is a Perl script. The role of the script is to
> search a flat file of key value pairs, find the key and return the
> value plus a few other lines. The script is called from the MRTG
> configuration file.
>
> The problem is that when running on Windows 98 with ActiveState's Perl
> I get the error message:
>
> Can't fork to start 'C:\perl\bin\perl C:\mrtg\run\mrtg_read.pl
> C:\_data\SFSK_HQA
> SDEV_oracle8.gum ora8_tablespace_usedspc_users': Bad file descriptor
> Could not get any data from external command 'C:\perl\bin\perl
> C:\mrtg\run\mrtg_
> read.pl C:\_data\SFSK_HQASDEV_oracle8.gum ora8_tablespace_usedspc_users'
> Maybe the external command did not even start. (Bad file descriptor)
>
> This occurs when there are too many "targets" in the file. This error
> does not
> occur on NT with the same version of MRTG. I suspect I'm bumping up
> against some sort of limit here because if I have only 1 or 2 targets
> it works fine. Each target means another instance of Perl that need
> gets fired up to search the file.
>
> Anyway the code for the actual Perl script is below, if anyone has a
> better method for searching a file for a key value pair in a flat file
> let me know.
>
> **Don't Laugh**
> open(METRIC, @ARGV[0]);
>
> while (<METRIC>) {
>
> ($ival, $utim, $nam) = split(/\|/);
> $nam == chop $nam;
> if ($nam eq @ARGV[1]) {
>
> print($ival,"\r\n","0","\r\n",$utim,"\r\n", $nam,"\r\n");
>
> }
>
> }
>
> close(METRIC);
> **Stop Laughing**
>
> -Ethan
> http://www.freetechnicaltraining.com
> http://www.gnumetrics.com
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
# nicer to me
my $file = shift @ARGV;
my $test = shift @ARGV;
open(METRIC, "$file") or die "sorry, but couldn't open file $file: $!\n";
while (<METRIC>) {
chomp; # HERE, damn it
($ival, $utim, $nam) = split(/\|/); # NOTE split /pattern/;
## look above ## $nam == chop $nam;
if ($nam eq $test) {
print($ival,"\r\n","0","\r\n",$utim,"\r\n", $nam,"\r\n");
}
}
close(METRIC);
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Tue, 12 Sep 2000 15:20:22 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <8plhis$ldh$1@nnrp1.deja.com>
In article <MPG.1426fd79598c517b989773@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> I'm not a big believer in 'qualifications' in the conventional sense
of
> the word .. but I did ask that everyone complete the following quick
> quiz .. I sprung it on the candidates and they had to complete it
> without referring to any references
>
> regulars in this group will be saddened to learn that out of 9
> unsuccessful candidates I received just three correct answers in total
> (not three correct quizzes .. but three correct answers) .. and that
was
> despite the fact that I basically gave away all the builtin variable
> related answers in the wording of the question
I didn't have trouble with your quiz, even though you did some naughty
things like array names made up of punctuation and <STDIN> when STDIN is
the default for <>(Assuming no arguements).
You may be suprised to know that when I got hired on this job, which
contains a lot of Perl development of special use tools and maintenance
of Perl/Tk legacy tools, that the interviewer asked me exactly one
technical question. "How do you declare a variable in Perl?" Sigh. Of
course I took that way too seriously and started asking clarifying
questions. "Scalar, Array or Hash?" All the interviewer wanted was
"With a Dollar sign." By the end of the interveiw I was at the team
leads desk helping her track down some problems she was having with
Inheritance in some of her scripts.
I got that job.
Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow
My newsreader limits sigs to four lines, but I cleverly bypassed this by
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Sep 2000 17:43:54 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <968779653.4550@itz.pp.sci.fi>
In article <slrn8rotnf.1bt.tjla@thislove.dyndns.org>, Gwyn Judd wrote:
>I was shocked! How could jason <elephant@squirrelgroup.com>
>say such a terrible thing:
>>
>>I'm not a big believer in 'qualifications' in the conventional sense of
>>the word .. but I did ask that everyone complete the following quick
>>quiz .. I sprung it on the candidates and they had to complete it
>>without referring to any references
I could answer each of your questions, but I would've - like you later
told some of your candidates did - complained about you disallowing
the use of reference material. The knowledge that interpolated arrays
are joined by $" while the arguments to print() are joined by $, isn't
really doing anything for me except taking up space in my mind. All I
_need_ to know is that the answer is in perlvar(1).
I'm currently employed as a Java programmer, but I couldn't write my
way out of a paper bag without Sun's javadocs at hand. I simply can't
be bothered to memorize the twisted jigsaw puzzle of strongly typed
method calls they like to call the core API. Especially the IO part.
>>3. Rewrite the following code so that it successfully does what
>> it's trying to do ?
>>
>> $x = (STDIN);
>> print 'You just typed $x/n';
>
>$x = <STDIN>;
>print "You just typed $x\n";
Questions like this are inherently ambiguous, but I would've omitted
the \n from the string since that is probably the desired effect. I
can just imagine the author posting here with "Subject: Double spaced
output!!!" after getting everything else right..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Tue, 12 Sep 2000 08:06:39 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Resolving IP's Q: Does this IP actually exist?
Message-Id: <ZDrv5.71$Xt4.122011@news.uswest.net>
"David Wall" <darkon@one.net> wrote:
> ralawrence@my-deja.com (Richard Lawrence) wrote in
> <8pkrv8$s89$1@nnrp1.deja.com>:
> >Can anyone advise me if it is possible to find out whether a site
> >exists quickly and easily within a certain amount of alloted time? If
> >anyones solution doesn't require connecting to a port then thats fine,
^^^^
> >because it means I can test first and then connect to the port
> >afterwards.
>
> How about Net::Ping?
He needs to find if ports are open, you can't do that with
a simple ICMP ECHO (Ping) request.
------------------------------
Date: 12 Sep 2000 12:59:57 -0400
From: darkon@one.net (David Wall)
Subject: Re: Resolving IP's Q: Does this IP actually exist?
Message-Id: <8FAD8A2ADdarkononenet@206.112.192.118>
christopher_j@uswest.net (Christopher M. Jones) wrote in
<ZDrv5.71$Xt4.122011@news.uswest.net>:
>
>"David Wall" <darkon@one.net> wrote:
>> ralawrence@my-deja.com (Richard Lawrence) wrote in
>> <8pkrv8$s89$1@nnrp1.deja.com>:
>> >Can anyone advise me if it is possible to find out whether a site
>> >exists quickly and easily within a certain amount of alloted time? If
>> >anyones solution doesn't require connecting to a port then thats fine,
> ^^^^
>> >because it means I can test first and then connect to the port
>> >afterwards.
>>
>> How about Net::Ping?
>
>He needs to find if ports are open, you can't do that with
>a simple ICMP ECHO (Ping) request.
I never claimed you could. I was suggesting ping as a quick and easy way to
see if a host exists and is reachable.
--
David Wall
darkon@one.net
------------------------------
Date: Tue, 12 Sep 2000 11:39:54 -0400
From: Steve Holden <sholden@holdenweb.com>
Subject: Re: Script To automate ftp uploading
Message-Id: <39BE4E4A.B7FDF783@holdenweb.com>
Moshe Eshel wrote:
>
> Hi!
>
> I need some help to create a script that will connect to a remote server and
> upload all the files in a certain directory.
>
> I know how to do the basic stuff like the connect and upload issues,
> what I really need help with are all the special cases... How to deal with
> Errors on the remote server, how to know when file upload has finished
> and do a size check to determine if the file made it to the other side...
> And if failed to retry... etc...
>
> Any help would be appriciated...
>
> Any examples in any shell language Perl or Tcl would be greatly
> appriciated...
>
> Thanks a lot in advance
>
> Moshe Eshel
> moshe@u4all.com
Moshe:
Your distribution may include a utility called "ftpmirror.py" which makes
use of the standard ftplib functions to do exactly what you want. In my
Windows 98 installation it lives at %PythonRoot%\Tools\Scripts.
Hope this helps.
regards
Steve
--
Helping people meet their information needs with training and technology.
703 967 0887 sholden@bellatlantic.net http://www.holdenweb.com/
------------------------------
Date: Tue, 12 Sep 2000 16:35:38 GMT
From: Roy Terry <royterry@earthlink.net>
Subject: Re: Script To automate ftp uploading
Message-Id: <39BE5AD4.8ED15C6B@earthlink.net>
Moshe Eshel wrote:
>
> Hi!
>
> I need some help to create a script that will connect to a remote server and
> upload all the files in a certain directory.
>
> I know how to do the basic stuff like the connect and upload issues,
> what I really need help with are all the special cases... How to deal with
> Errors on the remote server, how to know when file upload has finished
> and do a size check to determine if the file made it to the other side...
> And if failed to retry... etc...
>
> Any help would be appriciated..
I have implemented this sort of thing several times.
Your best bet involving Tcl would be to use the tcllib ftp package
then you can do open,get,ls, etc. from within your script. I've
used it a lot and it appears completely solid. Look for it at
http://dev.scriptics.com
If, for some reason, you don't want to use the native Tcl ftp package
then
you could use Tcl/Expect to run a command line ftp or you could use
Tcl/Expect/Telnet to run ftp on the remote machine. This last case gives
you the greatest visibility in to errors on the other side and you
could also run checksums, etc., but it is
almost certainly not worth the trouble. Also the expect solutions
require
UNIX or use of a special 8.0Tcl supporting expect on NT only (which
works
fine by the way).
In any case you are likely to end up "parsing" the output of an ftp
dir or list command. Here are pointers:
1. Beware of very large files for cases where the byte count is printed
next to the group name w/o intervening spaces.
2. Beware that you may need to swap the 3 date/time fields before you
pass them to clock scan based on whether it's a time + date or a date +
year.
3. Beware (especially) of file names containing spaces, dollar signs or
curly braces. Parse the list line with regexp and capture
all the characters beginning with the first word
following the date fields to end of line as literal file name.
Let me know if you'd like some Tcl code snippets for the above.
As far as handling errors, generally you can only report them and
move on. FTP transfers are almost always completely successful or
are obviously broken. If you want to though you could compare "ls"
output for each file on the remote and the local system (or checksums
as mentioned above).
>
> Any examples in any shell language Perl or Tcl would be greatly
> appriciated...
If you use the tcllib ftp package the examples will look very much
like command line ftp.
>
> Thanks a lot in advance
>
> Moshe Eshel
> moshe@u4all.com
------------------------------
Date: 12 Sep 2000 15:23:42 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use strict: why?
Message-Id: <8plhpv$ime$1@lublin.zrz.tu-berlin.de>
Jonathan Stowe <gellyfish@gellyfish.com> wrote in comp.lang.perl.misc:
>Anyhow using 'strict' gives you something to type in those awkward first
>moments of starting to write the program.
You mean writing a program in Perl isn't debugging an empty file?
Anno
------------------------------
Date: 12 Sep 2000 18:12:20 +0100
From: nobull@mail.com
Subject: Re: using filehandles in strict mode
Message-Id: <u9u2bl356z.fsf@wcl-l.bham.ac.uk>
tchrist@perl.com (Tom Christiansen) writes:
> In article <u97l8ibxem.fsf@wcl-l.bham.ac.uk>, <nobull@mail.com> wrote:
> >I'm guessing you mean you've got something like:
> >
> >my $fh = STDIN;
> >
> >You need to change that to:
> >
> >my $fh = \*STDIN;
>
> or simply:
>
> my $fh = *STDIN;
Huh? I don't get it. Doesn't that make $fh a symbolic reference?
Evidently not. So just what is the thing in $fh in this case?
I get null If I say:
my $fh = *STDIN; print ref $fh;
But GLOB if I do:
my $fh = \*STDIN; print ref $fh;
What is the difference between the two cases?
Why does ref() tell me that a scalar containing a typeglob is a plain
scalar?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4299
**************************************