[27850] in Perl-Users-Digest
Perl-Users Digest, Issue: 9214 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 2 14:05:49 2006
Date: Tue, 2 May 2006 11:05:04 -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, 2 May 2006 Volume: 10 Number: 9214
Today's topics:
Re: CGI Upload Problems <hal@thresholddigital.com>
Re: CGI Upload Problems xhoster@gmail.com
Re: CGI Upload Problems: SOLVED?? <hal@thresholddigital.com>
Re: CGI Upload Problems: SOLVED?? <glex_no-spam@qwest-spam-no.invalid>
new CPAN modules at Tue May 2 2006 (Randal Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 May 2006 06:28:20 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: CGI Upload Problems
Message-Id: <yfqdnQkg777YqcrZnZ2dnUVZ_s-dnZ2d@comcast.com>
Forgot to include with this that it is on a secure server, using an HTTPS
page instead of HTTP. I don't know if that makes a difference.
Hal Vaughan wrote:
> I've written Perl scripts to upload files before, but I'm having a lot of
> problems getting it to work in this case. I have a form with nothing
> outstanding about it and I'm simply trying to use the CGI::param(filename)
> to get the handle so I can read from it and write it to a file on my web
> server.
>
> I've snipped the other parts, since the form and Perl code would be long.
> Here's the basic form:
>
> <form method="post" action="/perl/upload.pl" name="DataUpload">
> UploadData: <input name="uploaddata" type="file">
> <input name="UploadData" value="Submit" align="left" type="submit">
> </form>
>
> And here's what I have in my upload.pl script:
> (again, the relevant parts, only)
>
> use CGI;
> $fname = CGI::param("file");
> $fdata = CGI::param("data");
> # $uhandle = CGI::param("uploaddata");
> $uhandle = CGI::upload("uploaddata");
> $tfile = "/var/www/data/temp.upload";
> open OUT, ">$tfile";
> binmode OUT;
> $fdata = <$uhandle> or cgilog("DEBUG Upload Error: $!");
> print OUT $fdata;
> close OUT;
>
> At this point I'm only testing this with a text file that is less than 50
> bytes long, so I'm not worried about reading in too much data at once.
> Once I've got it working, I'll replace that with a loop to read from the
> file handle with a specified buffer length and write to the output.
>
> cgilog() is my own logging routine that just dumps the log statements to a
> log file. In this case, I keep getting either "No such file or directory"
> as the error or no error reported at all. I also have uncommented the
> commented out line and used that to replace the line above it. It makes
> no difference.
>
> My guess is this is something extremely simple and obvious that I expect
> to be doing that I'm not because I've gone over this many times and spent
> hours on Google to try to find what I'm doing wrong, but I can't find a
> thing.
>
> This is for a system running Apache (1.3) on Linux.
>
> Thanks for any help.
>
> Hal
------------------------------
Date: 02 May 2006 14:52:02 GMT
From: xhoster@gmail.com
Subject: Re: CGI Upload Problems
Message-Id: <20060502110749.881$Ek@newsreader.com>
Hal Vaughan <hal@thresholddigital.com> wrote:
>
> I've snipped the other parts, since the form and Perl code would be long.
> Here's the basic form:
>
> <form method="post" action="/perl/upload.pl" name="DataUpload">
> UploadData: <input name="uploaddata" type="file">
> <input name="UploadData" value="Submit" align="left" type="submit">
> </form>
>
> And here's what I have in my upload.pl script:
> (again, the relevant parts, only)
>
> use CGI;
No use strict?
> $fname = CGI::param("file");
> $fdata = CGI::param("data");
What is the point of these two lines?
> # $uhandle = CGI::param("uploaddata");
> $uhandle = CGI::upload("uploaddata");
> $tfile = "/var/www/data/temp.upload";
> open OUT, ">$tfile";
Always check the success of open.
> binmode OUT;
> $fdata = <$uhandle> or cgilog("DEBUG Upload Error: $!");
It is not an error for a file-handle read to return a false value.
> print OUT $fdata;
> close OUT;
Usually check the success of close.
> At this point I'm only testing this with a text file that is less than 50
> bytes long, so I'm not worried about reading in too much data at once.
> Once I've got it working, I'll replace that with a loop to read from the
> file handle with a specified buffer length and write to the output.
CGI.pm already did this for you once (and your web server may have already
done it a second time.) You might want to look into simply copying the
temporary file that already exists.
> cgilog() is my own logging routine that just dumps the log statements to
> a log file. In this case, I keep getting either "No such file or
> directory"
Since reading an false value from a file-handle is not an error, the value
of $! after doing that is not meaningful. It is just left over from
whatever was in $! from some unknown point in the past.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 02 May 2006 09:58:16 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: CGI Upload Problems: SOLVED??
Message-Id: <o9KdnVWvCfrn-MrZRVn-jA@comcast.com>
This just does not make sense, but it fixes it. Any insight would be
appreciated.
I had a sample working that I had cut and pasted from a web page. I changed
the example script enough so it was working with the form I was already
using. I got it working without much trouble. Then I started copying over
lines from the non-working script to the example script. It worked fine.
Then I reversed the process, and it never would work.
I finally noticed the only difference was that the non-working script had 2
things the other didn't: "use strict;" and variable declarations with two
"our (...);" statements. It turns out if I declare $uhandle with all the
other variables, it does not work. The full script is rather short, so I
was declaring any variables that were used in the main script as "our" and
variables in routines as "my". (This isn't my normal way, but, again, this
script is short).
If $uhandle is declared as "our", it won't upload the file. If I declare it
with "my" it'll work. I've never seen a problem like this. Could it
somehow be interfering with the namespace in CGI or something else? I can
make this work now by just declaring it with "my", but does anyone know why
that makes a difference?
This is on Perl 5.6.0. The local server is 5.8.?, which would explain why
it worked on the local server and not the Internet one.
Hal
Hal Vaughan wrote:
> I've written Perl scripts to upload files before, but I'm having a lot of
> problems getting it to work in this case. I have a form with nothing
> outstanding about it and I'm simply trying to use the CGI::param(filename)
> to get the handle so I can read from it and write it to a file on my web
> server.
>
> I've snipped the other parts, since the form and Perl code would be long.
> Here's the basic form:
>
> <form method="post" action="/perl/upload.pl" name="DataUpload">
> UploadData: <input name="uploaddata" type="file">
> <input name="UploadData" value="Submit" align="left" type="submit">
> </form>
>
> And here's what I have in my upload.pl script:
> (again, the relevant parts, only)
>
> use CGI;
> $fname = CGI::param("file");
> $fdata = CGI::param("data");
> # $uhandle = CGI::param("uploaddata");
> $uhandle = CGI::upload("uploaddata");
> $tfile = "/var/www/data/temp.upload";
> open OUT, ">$tfile";
> binmode OUT;
> $fdata = <$uhandle> or cgilog("DEBUG Upload Error: $!");
> print OUT $fdata;
> close OUT;
>
> At this point I'm only testing this with a text file that is less than 50
> bytes long, so I'm not worried about reading in too much data at once.
> Once I've got it working, I'll replace that with a loop to read from the
> file handle with a specified buffer length and write to the output.
>
> cgilog() is my own logging routine that just dumps the log statements to a
> log file. In this case, I keep getting either "No such file or directory"
> as the error or no error reported at all. I also have uncommented the
> commented out line and used that to replace the line above it. It makes
> no difference.
>
> My guess is this is something extremely simple and obvious that I expect
> to be doing that I'm not because I've gone over this many times and spent
> hours on Google to try to find what I'm doing wrong, but I can't find a
> thing.
>
> This is for a system running Apache (1.3) on Linux.
>
> Thanks for any help.
>
> Hal
------------------------------
Date: Tue, 02 May 2006 10:03:46 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: CGI Upload Problems: SOLVED??
Message-Id: <gzK5g.5$4g6.4720@news.uswest.net>
Hal Vaughan wrote:
> This just does not make sense, but it fixes it. Any insight would be
> appreciated.
[...]
> If $uhandle is declared as "our", it won't upload the file. If I declare it
> with "my" it'll work. I've never seen a problem like this. Could it
> somehow be interfering with the namespace in CGI or something else? I can
> make this work now by just declaring it with "my", but does anyone know why
> that makes a difference?
>
> This is on Perl 5.6.0. The local server is 5.8.?, which would explain why
> it worked on the local server and not the Internet one.
The answer, or at least a good clue, should be found in your Web
server's error log. Hint: perldoc -f our
------------------------------
Date: Tue, 2 May 2006 04:42:05 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules at Tue May 2 2006
Message-Id: <IyMFq5.12zA@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Text-MeCab-0.01
http://search.cpan.org/~dmaki/Text-MeCab-0.01/
Alternate Interface To libmecab
----
Sman-0.99
http://search.cpan.org/~joshr/Sman-0.99/
Perl tool for searching man pages
----
WWW-Search-Yahoo-2.405
http://search.cpan.org/~mthurn/WWW-Search-Yahoo-2.405/
backend for searching www.yahoo.com
----
Test-Parser-1.2
http://search.cpan.org/~bryce/Test-Parser-1.2/
Base class for parsing log files from test runs, and displays in an XML syntax.
----
Test-Distribution-1.24
http://search.cpan.org/~srshah/Test-Distribution-1.24/
perform tests on all modules of a distribution
----
CGI-Widget-Tabs-1.12
http://search.cpan.org/~srshah/CGI-Widget-Tabs-1.12/
Create tab widgets in HTML
----
RRD-Simple-1.33
http://search.cpan.org/~nicolaw/RRD-Simple-1.33/
Simple interface to create and store data in RRD files
----
Data-Report-0.02
http://search.cpan.org/~jv/Data-Report-0.02/
Framework for flexible reporting
----
RT-View-Directory-1.6
http://search.cpan.org/~jesse/RT-View-Directory-1.6/
----
Database-Schema-Verification-1.01
http://search.cpan.org/~saxjazman/Database-Schema-Verification-1.01/
Perl extension for storing and verifing various levels of information
----
httpd_ctl-1.00
http://search.cpan.org/~srshah/httpd_ctl-1.00/
An apache control script that supports Template Toolkit pre-processing
----
Lingua-JA-Summarize-0.04
http://search.cpan.org/~kazuho/Lingua-JA-Summarize-0.04/
A keyword extractor / summary generator
----
Database-Schema-Verification-1.00
http://search.cpan.org/~saxjazman/Database-Schema-Verification-1.00/
Perl extension for storing and verifing various levels of information
----
RT-View-Directory-1.5
http://search.cpan.org/~jesse/RT-View-Directory-1.5/
----
PerlMaple-0.06
http://search.cpan.org/~agent/PerlMaple-0.06/
Perl binding for Maplesoft's Maple mathematical package
----
Net-Write-0.81
http://search.cpan.org/~gomor/Net-Write-0.81/
an interface to open and send raw frames to network
----
DateTime-TimeZone-0.45
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.45/
Time zone object base class and factory
----
NetAddr-IP-3.32
http://search.cpan.org/~luismunoz/NetAddr-IP-3.32/
Manages IPv4 and IPv6 addresses and subnets
----
Data-Table-1.45
http://search.cpan.org/~ezdb/Data-Table-1.45/
Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.
----
Language-Befunge-2.05
http://search.cpan.org/~jquelin/Language-Befunge-2.05/
a Befunge-98 interpreter
----
Net-DNS-Server-1.47
http://search.cpan.org/~luismunoz/Net-DNS-Server-1.47/
Perl extension to implement dynamic DNS servers
----
Tie-Mounted-0.16
http://search.cpan.org/~schubiger/Tie-Mounted-0.16/
Tie a mounted node to an array
----
Time-Decimal-0.05
http://search.cpan.org/~pfeiffer/Time-Decimal-0.05/
Handle french revolutionary ten hour days
----
ack-1.08
http://search.cpan.org/~petdance/ack-1.08/
grep-like text finder for large trees of text
----
Image-Info-1.21
http://search.cpan.org/~tels/Image-Info-1.21/
Extract meta information from image files
----
Tie-DiskUsage-0.14
http://search.cpan.org/~schubiger/Tie-DiskUsage-0.14/
Tie disk-usage to a hash
----
Data-Report-0.01
http://search.cpan.org/~jv/Data-Report-0.01/
Framework for flexible reporting
----
CPAN-Checksums-1.048
http://search.cpan.org/~andk/CPAN-Checksums-1.048/
Write a CHECKSUMS file for a directory as on CPAN
----
Class-Gomor-1.00
http://search.cpan.org/~gomor/Class-Gomor-1.00/
another class and object builder, base class only
----
Text-Balanced-1.97
http://search.cpan.org/~dconway/Text-Balanced-1.97/
Extract delimited text sequences from strings.
----
Net-OpenDHT-0.33
http://search.cpan.org/~lbrocard/Net-OpenDHT-0.33/
Access the Open Distributed Hash Table (Open DHT)
----
CGI-Persist-2.41
http://search.cpan.org/~sinister/CGI-Persist-2.41/
Web persistency made usable.
----
Lingua-AR-Db-2.0
http://search.cpan.org/~benazzo/Lingua-AR-Db-2.0/
Perl extension for translating Arabic words into another language
----
Apache-JemplateFilter-0.01
http://search.cpan.org/~fujiwara/Apache-JemplateFilter-0.01/
Jemplate complie filter for Apache
----
Apache2-JemplateFilter-0.02
http://search.cpan.org/~fujiwara/Apache2-JemplateFilter-0.02/
Jemplate complie filter for Apache2
----
RDF-Query-1.034
http://search.cpan.org/~gwilliams/RDF-Query-1.034/
An RDF query implementation of SPARQL/RDQL in Perl for use with RDF::Redland and RDF::Core.
----
Hatena-Keyword-0.04
http://search.cpan.org/~naoya/Hatena-Keyword-0.04/
Extract Hatena Keywords in a string
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
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:
#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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9214
***************************************