[18462] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 630 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 4 18:10:55 2001

Date: Wed, 4 Apr 2001 15:10:27 -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: <986422227-v10-i630@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 4 Apr 2001     Volume: 10 Number: 630

Today's topics:
    Re: How to create " Who is OnLine " page ? <moiraine{NOSPAM}@qwest.net>
    Re: HTML conversion <khera@kciLink.com>
    Re: LWP::Simple  problem <moiraine{NOSPAM}@qwest.net>
        managing open file descriptors w/ cacheout <plz@righthere.com>
        new user script help///verifying gcos field in passwd <isaacjade@home.com>
        newbie to Soap::Lite - unwanted messages <Steve_Alpert@idx.com>
    Re: newbie to Soap::Lite - unwanted messages <Steve_Alpert@idx.com>
    Re: Perl File Converter using all available memory. <thollowe@opentext.com>
    Re: Perl File Converter using all available memory. <uri@sysarch.com>
    Re: Perl Tutorial "Program Repair Shop and Red Flags" 2 <waltman@netaxs.com>
    Re: Please Flame my Benchmark: open vs. cat (Dave Bailey)
    Re: Please Flame my Benchmark: open vs. cat (Dave Bailey)
    Re: Please help (Dasdale)
    Re: Please help (John Joseph Trammell)
    Re: Please help <juex@deja.com>
        PPM package version of XML::XSLT <nospamplease@thankyou.com>
        Problem getting directory details using NET::FTP <dlungren@corecomm.net>
    Re: Q: LWP::UserAgent wont time out <jbc@west.net>
    Re: Remove every other character? (Mark Jason Dominus)
    Re: Search script <clinton.munden@alcatel.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 04 Apr 2001 13:30:23 -0700
From: A_Geekette <moiraine{NOSPAM}@qwest.net>
Subject: Re: How to create " Who is OnLine " page ?
Message-Id: <3ACB845F.9AEA5E2F@qwest.net>


--------------959C070F72F7DFB40D192156
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

If the users have shell access just utilize 'who', there's a module, but
I forgot what it was.
If they don't, then keep a db or a file (less efficient), that you
update when someone logs on or off.

Support wrote:

>  HiI created a small script that need a username and passwordbut I
> need a Page to tell Who is online from the users ?can I do this by
> cookies , and how ?RegardsPerl Lover

--
Geekette

"Try Not.  Do or do not.  There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)

"Nothing is impossible, no matter how improbable."
-Anonymous


--------------959C070F72F7DFB40D192156
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
If the users have shell access just utilize 'who', there's a module, but
I forgot what it was.
<br>If they don't, then keep a db or a file (less efficient), that you
update when someone logs on or off.
<p>Support wrote:
<blockquote TYPE=CITE>&nbsp;<font face="Arial"><font color="#000000"><font size=-1>Hi</font></font></font><font face="Arial"><font size=-1>I
created a small script that need a username and password</font></font><font face="Arial"><font size=-1>but
I need a Page to tell Who is online from the users ?</font></font><font face="Arial"><font size=-1>can
I do this by cookies , and how ?</font></font><font face="Arial"><font size=-1>Regards</font></font><font face="Arial"><font size=-1>Perl
Lover</font></font></blockquote>

<p>--
<br>Geekette
<p>"Try Not.&nbsp; Do or do not.&nbsp; There is no try."
<br>-If you don't know who said this,
<br>I don't want to talk to you. ;-)
<p>"Nothing is impossible, no matter how improbable."
<br>-Anonymous
<br>&nbsp;
</body>
</html>

--------------959C070F72F7DFB40D192156--



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

Date: 04 Apr 2001 14:35:30 -0400
From: Vivek Khera <khera@kciLink.com>
Subject: Re: HTML conversion
Message-Id: <x766gky0lp.fsf@onceler.kciLink.com>

>>>>> "TL" == Tim Lauterborn <Tim.Lauterborn@gmx.de> writes:

TL> alert-function). I can transform the letters replacing them step
TL> by step but what regular expression excludes HTML-comments?

No such regular expression can exist.  Check this newsgroup's archives
for why.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/


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

Date: Wed, 04 Apr 2001 13:20:17 -0700
From: A_Geekette <moiraine{NOSPAM}@qwest.net>
Subject: Re: LWP::Simple  problem
Message-Id: <3ACB8201.BAD5D363@qwest.net>

news-no-spam-group@home.com wrote:

> Hi,
>
> I need to install the LWP:: Simple  modules

<snip>
www.cpan.org
go to CPAN and download the CPAN module.   gunzip and tar it.
(man gunzip.  man tar.)
run:   perl Makefile.PL
(either CPAN will take over at this point or you'll have to run
make
make test
install
CPAN will get and install all the various things for you without you have to go
through all the trouble.  For the most part, it will also tell you if there are any
dependancies to satisfy.


perl -MCPAN -e shell
voila...type help and it will give you instructions or just say.
install LWP

--
Geekette

"Try Not.  Do or do not.  There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)

"Nothing is impossible, no matter how improbable."
-Anonymous




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

Date: Wed, 4 Apr 2001 13:00:01 -0700
From: "B McDonald" <plz@righthere.com>
Subject: managing open file descriptors w/ cacheout
Message-Id: <z4Ly6.47$_9.50233@news.pacbell.net>


Hi. I am unsuccessfully trying to use FileCache's cacheout function in order
to manage writing/appending to 12 simultaneously open files on my
Win98/ActivePerl 5.6.0.613 system. I'm not sure what I'm doing wrong -- and
unfortunately, upon conducting a search on FileCache and cacheout at
deja-googoo, I could not find any posts on the subject (either that's
strange... or I am strange...)

To summarize my application: I have a script that processes XML files...
which can generate a number of CSV output files for bulk load into SQL 7, if
specified through a command line option.

Here is my code (excerpted):

use Getopt::Long;
use XML::Parser;
use FileCache;

### first, i create the path to the directory where all the open files will
be created and written to...

# begin main
{
 # get command line options
 GetOptions ( 'resume' => \$resume, 'csvout' => \$csvout,
                      'import' => \$import, 'case=s' => \$case );

 my $casename = $case;
 $csvout_path = "./$casename/";        ##  THE PATH

<snip logic>

### next, i open(create) a bunch of CSV output files and print their
headers...

 if ($csvout) {
  # open a bunch of csv files for writing
  open (DOC, ">>./$casename/tblDocument.csv") || die "can't open
tblDocument.csv: $!";
  open (AUTH, ">>./$casename/tblAuthor.csv") || die "can't open
tblAuthor.csv: $!";
  open (RECI, ">>./$casename/tblRecipient.csv") || die "can't open
tblRecipient.csv: $!";
  ... ## 12 total open files

  # print HEADER line for each csv-formatted file
  print DOC "#field1name,field2name,etc.\n";
  print AUTH "#field1name,field2name,etc.\n";
  print RECI "#field1name,field2name,etc.\n";
  ... ## print header to all 12 open files
 }

<snip logic>

### parse xml files in directory...

 $p = new XML::Parser(Style => 'Stream', ErrorContext=>2);

 # loop over all files in the directory
 foreach $xmlfile (grep /\.xml$/, readdir(DIR)) {

  print "$xmlfile\n";

  # give the parser object a file and step back.
  $p->parsefile("$casename/$xmlfile");

 }

### then, within the looping xml file processing (and within XML::Parser's
### EndTag processing), the CSV output file writing occurs...
### the following is the print to the DOC filehandle case (there are 11
other
### similar cases)

  if ($import) {
   # inject document data -- not concerned with this case
   ...
  } elsif ($csvout) {
   cacheout $csvout_path . "tblDocument.csv";
   # generate csv-formatted bulk load file... write the current record
   print DOC "\"$doc_attrs{id}\",\"$doc_attrs{securitylev}\",
        \"$doc_attrs{produced}\",\"$doc_attrs{privilegetype}\",
        \"$doc_attrs{marginalia}\",\"$doc_attrs{partial}\",
        \"$doc_attrs{confidential_stamp}\",\"$doc_attrs{handwrit}\",
        \"$doc_attrs{email_thread}\",\"$doc_attrs{draft}\",
        \"$doc_attrs{redacted}\",\"$doc_attrs{illegible}\",
        ... etc.
        "\n";
  }

The path that is created is of this form:

 ./intel_v_rambus/tblDocument.csv

Does anyone have any idea if I am incorrectly invoking the cacheout
function... or if it cannot do what I want it to do?

Brian






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

Date: Wed, 04 Apr 2001 13:52:38 -0700
From: Isaac <isaacjade@home.com>
Subject: new user script help///verifying gcos field in passwd
Message-Id: <3ACB8996.8010103@home.com>

I am learning perl. Still new to it.
I am trying to edit our newuser script to add a field to the "gcos"  in 
passwd entries. I need to add a number at the end to signify if accounts 
are for employees or foreign nationals. 1=foreign 0=regular employee.
My problem is that if another admin runs the script and addes "let's say"

username:passwd:uid:gid:REAL NAME, mail stop, ext#: path
instead of just using  REAL NAME with no other entries like mail stop 
and ext#

then my code
#
# if foreign national write 1 to passwd entry
#
unless ($opt_us) {
   $ARGV[1]= "$ARGV[1],1";
}


is going to write the 1 to the wrong place in the passwd entry.
I need to know how to read  in what is being added to "gcos" so that my 
1 or 0 is always in the same place. This way I can write another script 
to give me a list of all foreign nationals if needed. Any ideas?
I hope I am making snese. It's hard to explain without posting the whole 
script (which is quite large).. Thanks in advance.



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

Date: Wed, 4 Apr 2001 12:14:04 -0400 
From: Steve Alpert <Steve_Alpert@idx.com>
Subject: newbie to Soap::Lite - unwanted messages
Message-Id: <11imct4ht1f0o5m13tsuilqp42ukc0qcd0@4ax.com>

I started playing with Soap::Lite and when I run my script I get a bunch of
lines like:

Subroutine qualify redefined at D:/Perl/site/lib/SOAP/Lite.pm line 62.
Subroutine overqualify redefined at D:/Perl/site/lib/SOAP/Lite.pm line 63.
Subroutine disqualify redefined at D:/Perl/site/lib/SOAP/Lite.pm line 64.
Subroutine clone redefined at D:/Perl/site/lib/SOAP/Lite.pm line 73.
Subroutine DESTROY redefined at D:/Perl/site/lib/SOAP/Lite.pm line 92.
Subroutine new redefined at D:/Perl/site/lib/SOAP/Lite.pm line 94.
Subroutine proxy redefined at D:/Perl/site/lib/SOAP/Lite.pm line 103.
Subroutine AUTOLOAD redefined at D:/Perl/site/lib/SOAP/Lite.pm line 124.

help!

tnx, steve

        Steve Alpert (Steve_Alpert @ i d x . c o m)
        IDX Systems Corp.   Boston, Massachusetts



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

Date: Wed, 4 Apr 2001 14:31:13 -0400 
From: Steve Alpert <Steve_Alpert@idx.com>
Subject: Re: newbie to Soap::Lite - unwanted messages
Message-Id: <71qmctcodlcgqb4le3nufee5do85jdm1de@4ax.com>

I know it's uncouth to follow-up your own messages, but..

I switched from Soap::Lite to SOAP::Lite and a lot of the problems went away.
Now I need to know how to pass in an XML body rather than just a string
parameter...
If I call my method TEST, I'd really like something like (ignoring name
spaces):

	<TEST>
		<VALUE deep='3'>abc</VALUE>
		<SIGMA>2.3</SIGMA>
	</TEST>

suggestions?

tnx, steve

        Steve Alpert (Steve_Alpert @ i d x . c o m)
        IDX Systems Corp.   Boston, Massachusetts



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

Date: Wed, 4 Apr 2001 14:42:15 -0400
From: "Skip Hollowell" <thollowe@opentext.com>
Subject: Re: Perl File Converter using all available memory.
Message-Id: <9afps2013dm@enews4.newsguy.com>

It appears as if the chomp command stores things and never releases them on
each call.  And since chomp iss being called 8.3 million times, it chews up
memory fast.  Took out the chomp and it runs at a cool 2 MB of memory total
for the whole conversion.

Skip Hollowell

nobull@mail.com wrote in message ...
>"Skip Hollowell" <thollowe@opentext.com> writes:
>
>> I have script that is processing a 1 GB file, and reformatting it.  The
>> problem is, it is using up every bit of memory on my system until it
>> eventually crashes out.  What am I missing in this line by line processor
>> that is not releasing memory?
>
>I can see no obvious memory leaks in your code.  Are you sure the file
>contains more than one line? (I.E. are you sure you are using the
>right end-of-line delimiter to read the file).
>
>--
>     \\   ( )
>  .  _\\__[oo
> .__/  \\ /\@
> .  l___\\
>  # ll  l\\
> ###LL  LL\\




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

Date: Wed, 04 Apr 2001 20:33:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl File Converter using all available memory.
Message-Id: <x7zodws8w2.fsf@home.sysarch.com>

>>>>> "SH" == Skip Hollowell <thollowe@opentext.com> writes:

  SH> It appears as if the chomp command stores things and never
  SH> releases them on each call.  And since chomp iss being called 8.3
  SH> million times, it chews up memory fast.  Took out the chomp and it
  SH> runs at a cool 2 MB of memory total for the whole conversion.

if you can demonstrate that in the latest perl (or even the dev release)
then report it as a memory leak with perlbug.

also don't jeopardy post. put your comments below edited parts of the
quoted posts.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 04 Apr 2001 14:25:45 -0400
From: Walt Mankowski <waltman@netaxs.com>
Subject: Re: Perl Tutorial "Program Repair Shop and Red Flags" 23 April 2001
Message-Id: <87lmpgzfme.fsf@netaxs.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> I am surprised perl.com alleges an editor; this is a relatively
> poorly written site containing an above average amount of errors in
> grammar, spelling, sentence structure and topic flow. I have read
> more poorly written sites for certain. However, a site such as
> perl.com which is associated with a publisher, O'Reilly, should
> present perfection in language usage.

<long, rather dubious rant against some alleged grammatical sins>

> With all due respect, Mr. Dominus, an editor worth the weight of her
> or his red line pencil, would not be merciful in editing your cited
> article; it would be left a bloody red mess, with prejudice, for
> your ironic misspelling of "misspell." Your article, although well
> intended and informative, is a reflection of the poor writing skills
> exhibited throughout perl.com's pages; it is riddled with awkward
> writing and, grammatical errors.
> 
> My opinion is, perl.com and O'Reilly are neither qualified
> nor entitled to lay claim to having an editor.

I find it amazing that you can find such fault with others, yet didn't
even notice, in your own quote from Mark, that he clearly stated:

> > At the time I wrote the description for the brochure, I was the
> > managing editor of www.perl.com, although I am no longer.

I believe Mark handed over his reins of editorial power(1) several
months ago.  Further, it you have complains about the quality of the
editing on www.perl.com, I humbly suggest that an email to either
perl.com or O'Reilly might be a more appropriate place to express
those concerns.

Walt Mankowski

1.  That's a metaphor, before you start flaming me, too.



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

Date: 04 Apr 2001 20:11:48 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Please Flame my Benchmark: open vs. cat
Message-Id: <slrn9cmlmt.a0d.dave@sydney.daveb.net>

On Wed, 4 Apr 2001 10:11:13 +0000 (UTC), Abigail <abigail@foad.org> wrote:
>Dave Bailey (dave@sydney.daveb.net) wrote on MMDCCLXXIII September
>MCMXCIII in <URL:news:slrn9cklep.71p.dave@sydney.daveb.net>:
>;; On Tue, 03 Apr 2001 23:46:13 -0000, Chris Stith 
>;; <mischief@velma.motion.net> wrote:
>;; >The fact that Abigail doesn't think it's normal to read the same
>;; >file for contents several thousand times in a program doesn't mean
>;; >she doesn't recognize the value of a benchmark. 
>;; 
>;; I didn't say that.  I was referring to her implication that the program
>;; which inspired the benchmark did this ("If I need a string 10,000 times
>;; in a program..."), and should be redesigned.  That was never indicated 
>;; by the original poster.  Perhaps all the program did was slurp a file 
>;; into a scalar and then exit.  It doesn't matter.  The question was, is it 
>;; faster to perform this task by backticking cat, or by slurping from Perl?
[...]
>For a single read, the difference between a backticked cat and slurping
>from Perl is as irrelevant as the question how many angles can dance on
>the tip of a needle. Because the time will be dominated by the disk read.

Yes, but after 10,000 reads, we finally see that the difference between
the two methods is essentially the time required for a fork() - which, 
apparently, would be a novel concept to the original poster's coworkers.
Since that is the essence of their misunderstanding, I feel that the 
benchmark is appropriate and sufficient to settle the disagreement.  It
is true that the extent to which the methods differ is dependent on the
size of the file being read (since cat does a memmove() to transfer the
input buffer to the output buffer), but the reality of the situation is
that a more detailed and thorough comparison of the two methods, while 
perhaps of use to you, would merely confuse the issue to the "cow orkers".

>;; There are lots of situations in computational physics where the inner 
>;; loop of a computation includes a division by something (say, x) which 
>;; is computed in an outer loop.  Such a computation can be made faster 
>;; by computing the reciprocal of x (call it y) in the outer loop and 
>;; replacing the inner-loop division by x with a multiplication by y.  
[...]
>Keyword "inner loop". Any program that does the same operation repeatedly
>in an inner loop has something that can be optimized away. 

I'd love to see you "optimize" the Gauss-Jordan elimination algorithm in
this manner.  See, for example, "Numerical Recipes in C", 2nd ed., p. 39
(near the bottom of the page) for a precise example of precomputation of 
a reciprocal to speed up loop processing:

http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf/c2-1.pdf

--
Dave Bailey
davidb54@yahoo.com


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

Date: 04 Apr 2001 20:24:48 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Please Flame my Benchmark: open vs. cat
Message-Id: <slrn9cmmf9.a0d.dave@sydney.daveb.net>

On Wed, 04 Apr 2001 10:22:54 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>I was shocked! How could Dave Bailey <dave@sydney.daveb.net>
>say such a terrible thing:
>
>>No.  People do tests like this all the time when benchmarking kernel 
>>system calls.  See http://www.kegel.com/dkftpbench/Poller_bench.html
>>for an example.
>
>Yeah but that's realistic for kernel system calls. See, kernel system
>calls can be called over and over again with the same arguments. The
>whole point of the kernel is after all to run as fast as possible. Even
>so, I bet they don't benchmark open(2) and read(2) with the same
>arguments over and over again, unless they are trying to figure out how
>well the cache performs.

You wouldn't do them both in the same test, but you might call open()
on the same file repeatedly just to see how fast open() is (or poll() on
the same set of file descriptors... etc).  Sometimes it's informative 
to see how efficiently different implementations or operating systems 
perform specific system calls.

[...]
>Well my contention is the benchmark was already useless so nothing is
>lost or gained.  The purpose of a benchmark is to provide some sort of
>estimate of how well a system would perform in real-life. Opening and
>reading in the same file over and over again is not realistic. If you
>have to do it 1000 times to tell the difference, then maybe there is no
>difference. 

Great, so you won't mind if I magically make integer addition 1000 times
slower on your machine, will you?  After all, you'd have to do it 
(integer addition) 1000 times to tell the difference, so maybe there 
is no difference.

--
Dave Bailey
davidb54@yahoo.com


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

Date: 04 Apr 2001 20:11:39 GMT
From: dasdale@cs.com (Dasdale)
Subject: Re: Please help
Message-Id: <20010404161139.25622.00002031@ng-bh1.news.cs.com>

i am reading that book, the first thing they teach is the script "hello world",
and i can't get that to run!. i have tryed vi and emacs, i can write the file,
but then i am opening up a terminal and trying to run, ...nothing happens.
should i be running it from someplace special? i am using the correct directoty
path, in the first line of the script. ...and thoughts?



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

Date: Wed, 04 Apr 2001 20:24:37 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Please help
Message-Id: <slrn9cmume.f2l.trammell@bayazid.hypersloth.net>

On 04 Apr 2001 20:11:39 GMT, Dasdale <dasdale@cs.com> wrote:
> i am reading that book, the first thing they teach is the
> script "hello world", and i can't get that to run!. 

Can you get the following command (command, not script) to run?

  perl -e 'print "Hello World\n"'



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

Date: Wed, 4 Apr 2001 13:30:02 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Please help
Message-Id: <3acb844e$1@news.microsoft.com>

"Dasdale" <dasdale@cs.com> wrote in message
news:20010404161139.25622.00002031@ng-bh1.news.cs.com...
> i am reading that book, the first thing they teach is the script "hello
world",
> and i can't get that to run!. i have tryed vi and emacs, i can write the
file,
> but then i am opening up a terminal and trying to run, ...nothing happens.
> should i be running it from someplace special? i am using the correct
directoty
> path, in the first line of the script. ...and thoughts?

If really nothing happens (no error message whatsoever) then I have a wild
guess: did you name the script "test"?
If yes then please try "which test" and see why it's not a good idea to name
a program "test". But this has more to do with UNIX shells than with Perl.

jue




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

Date: Wed, 4 Apr 2001 16:06:15 -0400
From: "null" <nospamplease@thankyou.com>
Subject: PPM package version of XML::XSLT
Message-Id: <9afuq8$4l7$1@bob.news.rcn.net>

I'm posting to ask whether anyone knows if there is a PPM package version of
the XML::XSLT module available anywhere.  Neither ActiveState or any of the
other repositories listed in their docs offers one and I need to install the
module locally so that I can work on some scripts.

I've posted to the perl-xml mailing list and emailed Bron Gondwana (the mod
author), but haven't received any responses.

I attempted to follow the instructions at ActiveState (and the advice at
http://jenda.krynicky.cz/perl/PPM.html) for producing a PPM package, but
can't get it to happen.

I am a perl novice and preparing a PPM pkg for a perl mod is probably a
trivial task for more experienced folk, but it's kicking my butt.  If there
isn't any existing PPK pkg for XML::XSLT (and I suspect that there probably
isn't) but someone is willing to make one, I would be grateful.

thanks,
brian








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

Date: Wed, 04 Apr 2001 16:33:16 -0500
From: Don Lundgren <dlungren@corecomm.net>
Subject: Problem getting directory details using NET::FTP
Message-Id: <3acb92ef$0$42872$1dc6e903@news.corecomm.net>

We have come upon a strange problem. We are connecting to an FTP server
using the NET::FTP module and when we run the dir command and pass it a
valid directory name that has content we are not returned any
information. It is as if the directory is blank(even when I know it is
not). This script has worked fine on each of the other 3 servers we
attach to. I am not sure where to proceed. Here is the sample code
condensed for ease and the resulting log file. Also the subject FTP
server is as follows an NT box OS - NT4.0  Spk 5 and MS FTP Service 4.0

#################################### Script file
########################
#/usr/bin/perl
use Net::FTP;
use Net::SMTP;

########### Configuration Area Begins Here ############
# FTP Server address, login and password
$ftpname="192.168.0.2";
$loginname="ftpuser";
$password='ftppassword3';

# Remote directory you wish to download from (SOURCE)
$remotedirname="/gage";

# 2nd Remote directory you wish to download from (SOURCE)
$remotedirname2="/trade1";

# File names allowed to be retreived # add or delete, 'file1',
'file2.html', 'file3txt', 'file4.zip'
@file_names  = ('clkpo', 'gage_order_header', 'gage_order_detail');

# File types allowed to be retreived # add or delete, 'htm', 'html',
'txt', 'zip'
@file_types  = ('ext');

# Local directory you wish to download to (DESTINATION)
$localdirname="c:/gage2/data";

# 2nd Local directory you wish to download to (DESTINATION)
$localdirname2="c:/trade2/data";

# Local report file (include full path or it will be placed in webserver
root directory)
$localrepfilename="c:/gage2/GetInternalFilesList.txt";

# Remote report file uploaded to SOURCE
$remoterepfilename="GetInternalFiles.ftp";

# Error report file (include full path or it will be placed in webserver
root directory)
$errorreport="c:/gage2/GetInternalFilesErrors.txt";

# Times to retry in event of file download failure
$countertry=5;

# Outgoing SMTP server
$smtpserver='some.mailserver.com';

# Email address of who report is to
$mailto='somebody@somebody.com';

# Email address of who report is from
$mailfrom='someone@somewhere.com';

# Email subject line
$mailsubject="Error in getting PCSXPROD ftp files";

########### Configuration Area Ends Here ############

# Connect to ftpsite
print "Connecting to $ftpname...";
$ftp=Net::FTP->new ($ftpname , Debug => 1 ) or errormessage("Can\'t
connect to FTP $ftpname - $!\n");
print "OK\n";

# Login to ftp site
print "Login as $loginname...";
$ftp->login($loginname,$password) or errormessage("Can\'t login as
$loginname - $!\n");
print "OK\n";

#### Get first set of files ####
### omitted because it is a couple of specific files and therefore no
directory listing is done and it works.

#### Get second set of files ####
&messageprint ("Get list dir $remotedirname2...");
my @lines=$ftp->dir($remotedirname2) or errormessage("Can\'t get listing
of $remotedirname2 - $!\n");
&messageprint ("OK\n");
foreach (@lines)
{
  if (substr ($_,0,1) eq "-")                       # download files
  {
    $filesize=substr($_,30)=~/(\d+\.?\d*|\.\d+)/;   # get file size
    $filesize=sprintf "%d",$1;                      # get file size
    $filename=&getfilename($');                     # get file name
(trunc after date)
 # Add support for specific file types
 foreach $type (@file_types) {
          # now lets check to see if the file type is allowed
          if($filename =~ /^.+(\.$type)$/i) {
       my $fil1=&createdirname($remotedirname2).$filename;
       my $fil2=&createdirname($localdirname2).$filename;
       &messageprint("Download $fil1($filesize) as $fil2 ... ");
       $filesizenew=0;
       my $i=0;
       while (($filesize!=$filesizenew) && ($i<=$countertry))
       {
          $ftp->type("I");
          if (!$ftp->get($fil1,$fil2,$filesizenew) && ($i==$countertry))

          {
              &errormessage("Error downloading file $filename - $!\n");
# get file from ftp
          }
          my @localfilestatstat=stat ($fil2);                     # get
info about file
          $filesizenew =
$localfilestatstat[7];                                         # get new
file size
          if ($filesize==$filesizenew)
          {   $msg="Download Successful"; }
          else
          {   $msg="RETRY..."; }
          &messageprint($msg);
          $i+=1;
       }
       &messageprint("\n");
          }
     }

  }
}

print "END.\n";
$ftp->quit;

######### Sub Routine Section ###########
sub createdirname
{
   my $dirname=shift @_;
   if ($dirname eq "/")
   { return $dirname; }
   else { return $dirname."/"; }
}

sub getfilename
{
  my $dirname= shift @_;
  $dirname=~m/(\d+):(\d+)/;        # get file name (trunc after date)
  return (substr($',1));           # get file name
}

sub errormessage
{
  my $errmsg=shift @_;
  print $errmsg;
  print STDERR $errmsg;
  close FILE;
  close STDERR;
  &mailsend;
  die $errmsg;
}

sub messageprint
{
  my $msgprn=shift @_;
  print $msgprn;
  print FILE $msgprn;
}

sub mailsend
{
  print "Sending error mail....";
  my $smtp=Net::SMTP->new($smtpserver,Timeout=>180);
  $smtp->mail($mailfrom) ;
  $smtp->to($mailto);
  $smtp->data();
  $smtp->datasend("To: $mailto\n");
  $smtp->datasend("From: $mailfrom\n");
  $smtp->datasend("Subject: $mailsubject\n");
  $smtp->datasend("Content-Type: text/plain\n");
  $smtp->datasend("\n");
  $smtp->datasend("Remote dir list:\n");
  $smtp->datasend("------------------\n");
  my @linesrep=@lines;
  foreach (@linesrep)
  {
    $smtp->datasend("$_\n");
  }
  $smtp->datasend("------------------\n");
  $smtp->datasend("\n\nDownload files:\n");
  $smtp->datasend("------------------\n");
  open(FILE,"$localrepfilename");
  binmode FILE;
  @linesrep=<FILE>;
  foreach (@linesrep)
  {
    $smtp->datasend("$_");
  }
  $smtp->datasend("------------------\n");
  close (FILE);
  $smtp->datasend("\n\nError messages:\n");
  $smtp->datasend("------------------\n");
  open(FILE,"$errorreport");
  binmode FILE;
  @linesrep=<FILE>;
  foreach (@linesrep)
  {
    $smtp->datasend("$_");
  }
  $smtp->datasend("------------------\n");
  close (FILE);
  $smtp->dataend();
  $smtp->quit;
  print "Ok.\n";
}


################### debugging log ################################
Net::FTP: Net::FTP(2.33)
Net::FTP:   Exporter(5.562)
Net::FTP:   Net::Cmd(2.11)
Net::FTP:   IO::Socket::INET(1.25)
Net::FTP:     IO::Socket(1.26)
Net::FTP:       IO::Handle(1.21)

Net::FTP=GLOB(0x8d526c4)<<< 220 pcsxprod Microsoft FTP Service (Version
4.0).
Net::FTP=GLOB(0x8d526c4)>>> user ftpuser
Net::FTP=GLOB(0x8d526c4)<<< 331 Password required for ftpuser.
Net::FTP=GLOB(0x8d526c4)>>> PASS ....
Net::FTP=GLOB(0x8d526c4)<<< 230-Hello !
Net::FTP=GLOB(0x8d526c4)<<< 230 User ftpuser logged in.
Net::FTP=GLOB(0x8d526c4)>>> SIZE /gage/clkpo
Net::FTP=GLOB(0x8d526c4)<<< 213 0
Net::FTP=GLOB(0x8d526c4)>>> SIZE /gage/gage_order_header
Net::FTP=GLOB(0x8d526c4)<<< 213 1139
Net::FTP=GLOB(0x8d526c4)>>> TYPE I
Net::FTP=GLOB(0x8d526c4)<<< 200 Type set to I.
Net::FTP=GLOB(0x8d526c4)>>> PORT 199,5,83,70,4,98
Net::FTP=GLOB(0x8d526c4)<<< 200 PORT command successful.
Net::FTP=GLOB(0x8d526c4)>>> RETR /gage/gage_order_header
Net::FTP=GLOB(0x8d526c4)<<< 150 Opening BINARY mode data connection for
/gage/gage_order_header(1139 bytes).
Net::FTP=GLOB(0x8d526c4)<<< 226 Transfer complete.
Net::FTP=GLOB(0x8d526c4)>>> SIZE /gage/gage_order_detail
Net::FTP=GLOB(0x8d526c4)<<< 213 178
Net::FTP=GLOB(0x8d526c4)>>> TYPE I
Net::FTP=GLOB(0x8d526c4)<<< 200 Type set to I.
Net::FTP=GLOB(0x8d526c4)>>> PORT 199,5,83,70,4,99
Net::FTP=GLOB(0x8d526c4)<<< 200 PORT command successful.
Net::FTP=GLOB(0x8d526c4)>>> RETR /gage/gage_order_detail
Net::FTP=GLOB(0x8d526c4)<<< 150 Opening BINARY mode data connection for
/gage/gage_order_detail(178 bytes).
Net::FTP=GLOB(0x8d526c4)<<< 226 Transfer complete.
Net::FTP=GLOB(0x8d526c4)>>> PORT 199,5,83,70,4,100
Net::FTP=GLOB(0x8d526c4)<<< 200 PORT command successful.
Net::FTP=GLOB(0x8d526c4)>>> LIST /trade1
Net::FTP=GLOB(0x8d526c4)<<< 150 Opening BINARY mode data connection for
/bin/ls.
Net::FTP=GLOB(0x8d526c4)<<< 226 Transfer complete.

########## end of debugging log #######################

Any help would be great.

Don Lundgren



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

Date: Wed, 04 Apr 2001 13:05:06 -0700
From: John Callender <jbc@west.net>
Subject: Re: Q: LWP::UserAgent wont time out
Message-Id: <3ACB7E72.13B5A9E5@west.net>

The News wrote:
> 
> I have been trying to get the LWP useragent to timeout when it encounters a
> URL that takes a long time to send a response back, but my application just
> keeps hanging.

I had a similar-sounding problem, which in my case was resolved
by upgrading the IO::Socket module in my site's Perl
installation, after I read the following mailing list message
from Gisle Aas:

http://www.ics.uci.edu/pub/websoft/libwww-perl/archive/1999h2/0438.html

My particular problem was apparently specific to Linux. The LWP
mailing list might be a good place to look for more-specific
answers. See:

http://charlotte.ics.uci.edu/pub/websoft/libwww-perl/

Good luck!

John Callender
jbc@west.net


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

Date: Wed, 04 Apr 2001 18:50:25 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Remove every other character?
Message-Id: <3acb6cf0.6db0$3ce@news.op.net>
Keywords: Eric, burette, cheese, film

In article <3ACB53C5.E82C9536@northwestern.edu.invalid>,
Dmitry Epstein  <mitiaNOSPAM@northwestern.edu.invalid> wrote:
>> TMTOWTDI:
>
>Huh?

Perl's motto is:

        There's More Than One Way To Do It.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 04 Apr 2001 17:33:53 -0400
From: Clinton Munden <clinton.munden@alcatel.com>
Subject: Re: Search script
Message-Id: <3ACB9341.6CCCC8F3@alcatel.com>

If you have the search script then stick with it.  You won't find many, if any
scripts that will include html templates.
What I suggest you do is put your own html into the script that you already
have.   Just stay below this line
   print "Content-type: text/html\n\n";    -->>

and then put your own blocks of html around the html that the scripts spits
out.  Something like this:

   print "Content-type: text/html\n\n";            # this is somewhere in your
script
   print "<html><head><title>sometitle</title></head><body>\n";
   print <<EOF;                                          # put this before the
script's html
   # put your html here.  A whole bunch of it if you like.
   EOF                                                       # put this under
your own html (with no beginning or trailing whitespaces)
   # this will be the scripts html output
   print <<EOF;                                           #put this after the
script's html
   # put more of your html here.  probable the footer of your page
   EOF                                                        #put this under
your own html again
   print "</body></html>\n";

Hope this helps.

Clinton Munden



Fraggler? wrote:

> Sorry if this is off topic or the wrong news group, but hey, I'm new.
>
> I'm looking for a search script.  I have an old one which is a CGI script
> (and I belive it's written in perl) but I'm very dissatisfied with it,
> especially since I can't have it write the search  results to a page that
> already has stuff on it, like the buttons and graphics common to every page
> of our site.
>
> I just need a search script that will search pages only on the local site
> and can be configured to write to a page with content, or even write the
> common content (buttons and graphics) along with the search results.
>
> Does anyone know of any links to such scripts?
>
> Thanks!
>
> --
>
> -Fraggler?
>
> www.reality-syndicate.com
> A forum for the free exchange
> of abnormal ideas and media!



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

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 V10 Issue 630
**************************************


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