[17846] in Perl-Users-Digest
Perl-Users Digest, Issue: 6 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 6 14:05:40 2001
Date: Sat, 6 Jan 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978807909-v10-i6@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 6 Jan 2001 Volume: 10 Number: 6
Today's topics:
Re: A Socket Server Problem <schelling@bluewin.ch>
Re: Any good Perl books? <bcaligari@my-deja.com>
Re: Beginner cgi question.. tohann@my-deja.com
Re: Beginner cgi question.. nobull@mail.com
CGI error trying to parse <djo22@cornell.edu>
Re: CGI error trying to parse nobull@mail.com
Re: CGI error trying to parse <bjoern@hoehrmann.de>
Could I remotely zip a file before I get it by FTP <wstsoi@netvigator.com>
Re: Could I remotely zip a file before I get it by FTP nobull@mail.com
Re: Could I remotely zip a file before I get it by FTP (Abigail)
distributing perl.dll with commercial sw nmaddix@bb2w.com
Re: e-mail to perl gateway... (Web Your Business)
files in directory <snef@soneramail.nl>
Re: files in directory (Tad McClellan)
Re: files in directory (Mark Jason Dominus)
Looking for program html form to cgi (Hosehead)
Re: Modify @INC? (Mark Jason Dominus)
Re: Need help inserting commas in a string.. (Tad McClellan)
Re: Net::Telnet and --More-- <neil@alaweb.com>
Re: Net::Telnet and --More-- (Garry Williams)
Re: Newbie but serious - Problems reading file from mul (Tad McClellan)
Re: Newbie but serious - Problems reading file from mul <joe+usenet@sunstarsys.com>
Re: Newbie but serious - Problems reading file from mul (Mark Jason Dominus)
Re: Newbie but serious - Problems reading file from mul (Mark Jason Dominus)
Re: Newbie but serious - Problems reading file from mul (Mark Jason Dominus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 06 Jan 2001 17:58:04 +0100
From: Bernhard Schelling <schelling@bluewin.ch>
Subject: Re: A Socket Server Problem
Message-Id: <3A574E9C.E3C8B763@bluewin.ch>
Hi
mmh, what you mean?
I accept the connection, and add it to a select. The client never send any
data after the connection (I read this with sysread out).
Then I go through all handles with @handles = $select->handles and give them
the new data.
But before this, I want to close all connection, who "closed their browser".
I tried
for ($i=1;$i<@handles;$i++)
{
$select_thishandle=IO::Select->new($handles[$i]);
@selhandles = $select_thishandle->handles;
if ($select_thishandle->can_read(0.1) > 0)
{
$select_telnet->remove($handles[$i]);
$handles[$i]->close;
}
}
This only worked if I connected locally, but not over a proxy.
thanks a lot for your help!
bye
Per Kistler schrieb:
> Hi
>
> Does the standard thing, that the socket says it's readable but if
> you read nothing shows up, not work here?
>
> Per.
>
> Bernhard Schelling wrote:
> I have a Perl socket server connecting with a httpclient.
> I need a longer multipart connection, but thats not the problem.
> How do I know, when a client disconnects? (closes his browser)
> My program just doesn't know, when the socket connection isn't open
> anymore. My program can close the connection at any time, and the
> browser puts up a messagbox.
>
> --
> Per Kistler, Zurich, Switzerland
> ------------------------------------------------------------------------
------------------------------
Date: Sat, 06 Jan 2001 18:50:41 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Any good Perl books?
Message-Id: <937pdv$kq$1@nnrp1.deja.com>
In article <slrn95b69k.nsr.abigail@tsathoggua.rlyeh.net>,
abigail@foad.org wrote:
> Damian James (damian@puma.qimr.edu.au) wrote on MMDCLXXXIV September
> MCMXCIII in <URL:news:slrn95abh9.8ag.damian@puma.qimr.edu.au>:
> ;; In article <slrn9593ia.qdu.abigail@tsathoggua.rlyeh.net>, Abigail
wrote:
> ;; >
> ;; >Bad ones: ...
> ;; > Advanced Perl Programming
> ;; > Mastering Algorithms with Perl
> ;; >
> ;;
> ;; Just out of interest, I was wondering what your problem with
> ;; these two might be.
> ;;
> ;; I think I can guess -- is it because they might lead the novice
> ;; programmer to the conclusion that s/he needn't go and read
standard
> ;; the Comp Sci texts on similar subjects?
> ;;
> ;; I have been reading the latter book recently, and found it
enlightening
> ;; within bounds (but would hate to think it is teaching me _bad_
things).
>
> APP touches many subjects, without going deeply into them. MAP never
> made up its mind whether it wanted to deal with algorithms, whether
> it wanted to be a bag of trick, or whether it wanted to promote some
> CPAN modules. As it result, it doesn't do any of them well. Somewhere
> in the introduction, MAP says that most textbooks on algorithms use
> pseudo-code and not a "real language". The rest of MAP shows how right
> those textbooks are.
>
> Abigail
I have been playing about with perl for some 6 months, trying to fit in
some perl every so often. Whilst my life does not revolve around Perl,
my perl library (part personal, part employer's) is 7 title rich. 6 of
these titles are all oreilly...the other being the brilliant Object
Oriented Perl.
I agree with you that texts such as "learning perl" may not be the end
of the world, but it helped me get started off, and within a couple of
weeks of 'LP' only, I had scrapped most awk/shell stuff.
AAP on the other hand started me off at perl things which the Camel
book did a very good job at intimidating.
Brendon
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 06 Jan 2001 16:45:37 GMT
From: tohann@my-deja.com
Subject: Re: Beginner cgi question..
Message-Id: <937i3f$r5i$1@nnrp1.deja.com>
In article <9378gc$dqs$1@news.kolumbus.fi>,
"Wavetable" <wavetable@birdmail.com> wrote:
> This is a really simple question but as I haven't found the answer
anywhere
> I'll try it here. I don't know really anything about perl/cgi...
> How do you read parameters in cgi programs? I have tried the
$QUERY_STRING
> method with #!/usr/local/bin/perl but it doesn't work, yet it works
with
> #!/bin/sh. Thanks..
>
>
I'm not an expert in this field, but here are my initial thoughts. It
looks like you're reading the environment variable when you use the
#!/bin/sh. That # directive makes it a script file rather than a perl
program. Have you looked into using the CGI.pm module? More
specifically the query() method? That may be what you need.
Hope this helps,
Trent O.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 06 Jan 2001 17:54:55 +0000
From: nobull@mail.com
Subject: Re: Beginner cgi question..
Message-Id: <u94rzclg5s.fsf@wcl-l.bham.ac.uk>
"Wavetable" <wavetable@birdmail.com> writes:
> This is a really simple question but as I haven't found the answer anywhere
Perl comes with many standard modules. The one for writing CGI
scripts in Perl is called CGI.
> I'll try it here. I don't know really anything about perl/cgi...
Perl is a general purpose programming language.
CGI is an interface specification between web servers and server-side
program used on a web site. These programs can be written in any
programming language (including Perl).
> How do you read parameters in cgi programs?
See documentation on CGI.
> I have tried the $QUERY_STRING
> method with #!/usr/local/bin/perl but it doesn't work, yet it works with
> #!/bin/sh. Thanks..
You will find that different programming languages are
well... different. A line of code that works in one programming (say
Bourne shell) may mean something different in a different programming
language (say Perl).
In Bourne shell $QUERY_STRING refers to the environment variable
QUERY_STRING. In Perl you'd refer to the same as $ENV{QUERY_STRING}.
However you seriously do not what to be rolling our own CGI
implementation in Perl - use the standard module.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 6 Jan 2001 11:54:14 -0500
From: "Dan O'Connor" <djo22@cornell.edu>
Subject: CGI error trying to parse
Message-Id: <937ijq$6vd$1@news01.cit.cornell.edu>
Hello,
I'm trying to parse other web pages with my page, but I'm getting the
following error:
CGI Error
The specified CGI application misbehaved by not returning a complete set of
HTTP headers. The headers it did return are:
Can't locate object method "handler" via package "HTML::Parser" at
D:\WWW\...\getweather.pl line 155.
The problem in my code it's pointing to is this...
my $p = HTML::Parser->new(api_version => 3);
$p->handler( start => \&start_handler, "tagname,self");
<------------- line 155
$p->parse($content) || die $!;
I've tried several other parsing examples that seem to work on other servers
and I keep getting errors. Do you think this is because of my server?
Thanks a ton,
Dan
------------------------------
Date: 06 Jan 2001 18:03:43 +0000
From: nobull@mail.com
Subject: Re: CGI error trying to parse
Message-Id: <u91yuglfr4.fsf@wcl-l.bham.ac.uk>
"Dan O'Connor" <djo22@cornell.edu> writes:
> Subject: CGI error trying to parse
Problem has nothing to do with CGI or parsing, or even Perl for that
matter. Your problem relates simply to the use of libraries in
programming.
> Can't locate object method "handler" via package "HTML::Parser" at
> I've tried several other parsing examples that seem to work on other servers
> and I keep getting errors. Do you think this is because of my server?
Yes. Think! You find that on one computer a particular package (or
library) appears not to implement a method (or function or feature)
that is does implement on other computers you have used. Your first
thought should be that you may have a older version of the library
that predates the introduction of the missing feature. (There are
other possibilites but this should definitely be our first thought).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 06 Jan 2001 20:03:22 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: CGI error trying to parse
Message-Id: <3a665bec.9466421@news.bjoern.hoehrmann.de>
* Dan O'Connor wrote in comp.lang.perl.misc:
> I'm trying to parse other web pages with my page, but I'm getting the
>following error:
>
>CGI Error
>The specified CGI application misbehaved by not returning a complete set of
>HTTP headers. The headers it did return are:
>Can't locate object method "handler" via package "HTML::Parser" at
>D:\WWW\...\getweather.pl line 155.
Are you sure you've got a
use HTML::Parsser;
statement before you create an instance of the package? Are you using
CGI.pm and do you print any headers, i.e.
use CGI ':standard';
print header;
print "<p>Hello CGI-World</p>";
You script does not run from the command line, does it? I hope you
aren't debugging your scripts in your browser...
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
"I am told that God is in these newsgroups. Does he post here often ?"
------------------------------
Date: Sat, 6 Jan 2001 23:55:03 +0800
From: "Regent Linus" <wstsoi@netvigator.com>
Subject: Could I remotely zip a file before I get it by FTP
Message-Id: <937egf$kpg3@imsp212.netvigator.com>
How could perl do this?
I need to get a large text file
Thanks
------------------------------
Date: 06 Jan 2001 17:39:14 +0000
From: nobull@mail.com
Subject: Re: Could I remotely zip a file before I get it by FTP
Message-Id: <u98zoolgvx.fsf@wcl-l.bham.ac.uk>
"Regent Linus" <wstsoi@netvigator.com> writes:
> How could perl do this?
First tell us how you would do "this" if Perl wer not involved.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 6 Jan 2001 18:54:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Could I remotely zip a file before I get it by FTP
Message-Id: <slrn95eqef.94m.abigail@tsathoggua.rlyeh.net>
Regent Linus (wstsoi@netvigator.com) wrote on MMDCLXXXV September
MCMXCIII in <URL:news:937egf$kpg3@imsp212.netvigator.com>:
^^ How could perl do this?
There are various ways. You could use UUCP to give a remote command.
Or you could NSF mount the drive the file is on, then zip it. Or
install (write?) an FTP server that zips on the fly. Perl doesn't
really play much of a role in all of this though.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Sat, 06 Jan 2001 15:51:20 GMT
From: nmaddix@bb2w.com
Subject: distributing perl.dll with commercial sw
Message-Id: <937etn$ojc$1@nnrp1.deja.com>
Hope someone can help... I've written a piece of commercial software in
c++ that embeds small amounts of perl code and links with perl56.dll.
All I need to do is distribute the dll with the application and I'm good
to go.
The problem is... is it legal to distribute perl56.dll with a commercial
application? The perl artistic license seems to say this is OK, but
doesn't address the dll directly. Can anyone point me to a more
closely-related source of information on this specific situation?
Thanks,
Nick
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 06 Jan 2001 15:37:50 GMT
From: webyourbusiness@home.com (Web Your Business)
Subject: Re: e-mail to perl gateway...
Message-Id: <webyourbusiness-0601010837240001@192.168.0.3>
In article <slrn95av5s.du5.rgarciasuarez@rafael.kazibao.net>,
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> Web Your Business wrote in comp.lang.perl.misc:
> > It's probably been asked, but I can't find it.. perhaps I'm searching for
> > the wrong thing, but here goes:
> >
> > I'm after information on how to write scripts (Perl and [ba]sh) and C
> > binaries that I can trigger off by e-mail to a particular address...
>
> This is not really a Perl question then... This is related to your mail
> server. For example, with sendmail, the usual way to do this is to
> define an alias
> address: "|/path/to/program"
> Read the docs for your mail server; find a newsgroup for it.
thanks
--
http://www.webyourbusiness.com - making award winning e-commerce
solutions affordable. Download your trial for free:
US:http://www.webyourbusiness.com/cgi-bin/redirector.cgi?l=newsinfoUS
EU:http://www.webyourbusiness.com/cgi-bin/redirector.cgi?l=newsinfoUK
------------------------------
Date: Sat, 6 Jan 2001 15:05:36 +0100
From: snef <snef@soneramail.nl>
Subject: files in directory
Message-Id: <MPG.14c1449a326489f19896fd@news.soneraplaza.nl>
Hi.
I want a script to get files out a directory (if there are any), read
them and delete them. (and later; when something goes wrong in the
script, I want to save the file in another directory.)
So far I've made a little script:
#!/usr/bin/perl -w
# get filenames out directory
open (DIR,"./dirname");
while ($name = readdir(DIR));
next if $name !~ /^\w/;
push(@files, $name);
}
close(DIR);
# read files & delete
foreach $file (@files) {
undef ($/);
open(FILE,"$file");
$read=<FILE>;
close(FILE);
unlink <./dirname/$file>;
}
I think it can be done more efficient (?) or in a different manner. Can
somebody give my some tips/hints?
Thanx!
Snef
------------------------------
Date: Sat, 6 Jan 2001 09:37:13 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: files in directory
Message-Id: <slrn95ebcp.sgh.tadmc@magna.metronet.com>
snef <snef@soneramail.nl> wrote:
>
>I want a script to get files out a directory (if there are any), read
>them and delete them. (and later; when something goes wrong in the
>script, I want to save the file in another directory.)
>
>#!/usr/bin/perl -w
use strict;
># get filenames out directory
>open (DIR,"./dirname");
You need to call opendir() for directories. open() is for files.
You should check the return value too:
opendir(DIR, './dirname') or die "could not open './dirname' directory $!";
>while ($name = readdir(DIR));
> next if $name !~ /^\w/;
> push(@files, $name);
>}
You can replace that whole loop with one statement:
my @files = grep /^\w/, readdir(DIR);
>foreach $file (@files) {
You don't need the temp @files array at all:
foreach $file ( grep /^\w/, readdir(DIR) ) {
> unlink <./dirname/$file>;
Globbing is dangerous there (what if $file = 'foo*.bar'?), you
should use a string instead, else you may be deleting more than
a single file:
unlink "./dirname/$file";
And if you care whether or not the file was actually removed, then
you better check the return value here too:
unlink "./dirname/$file" or die "could not unlink './dirname/$file' $!";
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 06 Jan 2001 18:29:08 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: files in directory
Message-Id: <3a5763f4.1df$4f@news.op.net>
In article <MPG.14c1449a326489f19896fd@news.soneraplaza.nl>,
snef <snef@soneramail.nl> wrote:
>I want a script to get files out a directory (if there are any), read
>them and delete them. (and later; when something goes wrong in the
>script, I want to save the file in another directory.) I think it
>can be done more efficient (?) or in a different manner. Can somebody
>give my some tips/hints?
The way you did it is fine, and is aprobably about as efficient as any
other method people will come up with. I saw two small but serious
problems that I saw were that you changed the value of $/ and did not
put the old value back when you were done. It is a good practice to
use 'local' when you change the value of $/:
foreach $file (@files) {
local $/;
undef ($/);
...
}
The 'local' expression tells Perl to save the old value of $/ and to
arrange to restore the old value automatically when control leaves
trhe 'foreach' loop. That way you can't forget to put the old value
back, because it happens automatically.
The other problem is that
unlink <./dirname/$file>;
does not do what you mean. You want to use
unlink "./dirname/$file";
instead. <...> does a pattern-matching operation and produces a list
of all the matching files. This could cause problems if $file
happened to contain a '*' or '?' character.
If you wanted to use less code, you should follow Tad's suggestions.
But here is a tricky alternative that may amuse you:
{ my @files = grep m{/\w[^/]*$}, glob("./dirname/*");
local $/ = undef;
local @ARGV = @files;
my @file_data = <>;
# use @file_data here
unlink @files;
}
glob("./dirname/*") constructs a list of all the files in the
directory "./dirname". The 'grep' filters the list and returns only
the names whose final component begins with a \w character.
The real trick is in the @ARGV manipulation. We set @ARGV temporarily
to the list of interesting files. The next line uses <> to read data
into @file_data. <> means to read from the files named in @ARGV,
which we just set to contain a list of files of interest.
<> returns a list of 'records'. But because $/ is set to undef, each
read from <> returns the contents of an entire file. @file_data has
one element per file; each element is the contents of an entire file.
--
@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: Sat, 06 Jan 2001 17:33:32 GMT
From: rich@mrinter.net (Hosehead)
Subject: Looking for program html form to cgi
Message-Id: <3a574d32.5699309@news.artnet.net>
Looking for a windows program (freeware or shareware) that will import
an existing html form and create the cgi script to update a flat file
database. Also to be able to search that database and display a html
page that looks like the original form layout.
TIA
------------------------------
Date: Sat, 06 Jan 2001 18:33:37 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Modify @INC?
Message-Id: <3a576501.1f1$25e@news.op.net>
In article <slrn95dmh1.la.mgjv@martien.heliotrope.home>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>But it does have something to do with -T.
>
>You could just put the current directory back in @INC, with the lib
>pragma. That's what it's for:
If you do this, you are disabling a security mechanism. '.' was
removed from @INC for a good reason. It is probably better to figure
out the absolute path of the directory with the modules, and put that
into @INC instead. In any case, caution should be exercised.
--
@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: Sat, 6 Jan 2001 07:40:57 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need help inserting commas in a string..
Message-Id: <slrn95e4ip.ri8.tadmc@magna.metronet.com>
Roger Hinson <hinson@home.com> wrote:
>
>Here is the portion of a script I am using to reorganize a text file.
>
>for($x = 7; $x < @template; $x++) { ### This takes care of multiple
> if ( "$template[$x]" ) { ### This makes sure the line has
The double quotes do not do anything useful, so they should not be there:
if ( $template[$x] ) {
And your code does _not_ make sure that it has "info".
It makes sure that the value of $template[$x] is true.
$template[$x] could contain numeric zero or the string '0'
and your if() would miss it. If you are sure that they
cannot be those values, then you still need to change
the comment, because the code doesn't really do what
you say it does.
You do not say what constitutes "info" so I can't say what
you should really use instead. Maybe it is one of these:
if ( length $template[$x] ) { # has at least 1 char in it
if ( defined $template[$x] ) { # is not undef
if ( $template[$x] !~ /^\s*$/ ) { # no lines with only spaces
>And this is an example of one of the lines I'm getting as a result.
>Sorry about the word wrap.
Why don't you just fix the word wrap?
(in your code. Can't do much about the length of data lines)
Particularly in code. You should write your code in less that
80 characters anyway, just so word wrapping cannot break it.
I deleted the wrapped part of the comments because they cause
syntax errors.
>What I would like to do is put commas into the string so that it's
>easier to import into Excel with the Excel wizard.
Use one of the CSV modules for creating CSV data.
You can get Perl modules from CPAN.
>I don't want to get a comma after each word, but they are always the
>same positions.
^^^^^^^^^^^^^^
That is useful information that should make Perlified brains start
saying "unpack, unpack, unpack".
perldoc -f unpack
> I think it has to do with split,
Nope.
pack/unpack is for fixed-width data.
split is for "something separated" data (variable-width data).
Use unpack() to get the fields, use CSV.pm or similar to put
them back together with commas (or use join() if you are *sure*
that there can never be commas in your data).
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 6 Jan 2001 08:46:59 -0600
From: "Neil" <neil@alaweb.com>
Subject: Re: Net::Telnet and --More--
Message-Id: <t5ebulqe4qut29@corp.supernews.com>
"H Chosta" <h0c2000@yahoo.com> wrote in message
news:t5d1htamg83b71@corp.supernews.com...
> I had a similar issue with Cabletron routers. After trying to get it
> working for an hour, I gave up and had my script shut off page
> scrolling, get whatever, and then turn scrolling back on and log off.
> There was probably a better way to do it, but it worked for me.
> Henry
>
Thanks ! I have searched under deja and a have done a general web search to
see how to turn off the --More-- feature, which may be the "scrolling" that
you are talking about, and have yet to find a way to do this.....
Any help is greatly appreciated,
Neil
------------------------------
Date: Sat, 06 Jan 2001 17:56:04 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Net::Telnet and --More--
Message-Id: <U_I56.49$UQ5.2736@eagle.america.net>
On Sat, 6 Jan 2001 08:46:59 -0600, Neil <neil@alaweb.com> wrote:
>"H Chosta" <h0c2000@yahoo.com> wrote in message
>news:t5d1htamg83b71@corp.supernews.com...
>> I had a similar issue with Cabletron routers. After trying to get it
>> working for an hour, I gave up and had my script shut off page
>> scrolling, get whatever, and then turn scrolling back on and log off.
>> There was probably a better way to do it, but it worked for me.
>> Henry
>>
>Thanks ! I have searched under deja and a have done a general web search to
>see how to turn off the --More-- feature, which may be the "scrolling" that
>you are talking about, and have yet to find a way to do this.....
You should really take this discussion elsewhere. The Cisco IOS
command you're probably looking for is:
terminal length 0
Not a Perl question.
Check the Cisco doc or simply the on-line help at the IOS prompt.
--
Garry Williams
------------------------------
Date: Sat, 6 Jan 2001 08:30:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no binmode!) (repost)
Message-Id: <slrn95e7gj.ri8.tadmc@magna.metronet.com>
Patrick Holthuizen <pholthuizen@celwood.com> wrote:
>I've asked this before, but I didn't receive any reactions.
"Why Questions go Unanswered":
http://perl.plover.com/Questions.html
>Here it is
>again, please help me out.
Help yourself out by not wasting your P40CoS (Precious 40 Characters
of Subject).
"Newbie but serious - " adds no useful information, and is indeed
a "red flag" that causes your article to be scored down, which
may render it "invisible" to someone who knows the answer you
are seeking. You can put that in the body if you must, but
spending Subject characters on it is unwise.
"Problems " adds no useful information either. Nearly all posts
here are about problems.
Your post is in competition with 100-200 others each day. The
ones with the best Subject win.
For how to win, see:
http://www.perl.com/CPAN-local/authors/Dean_Roehrich/subjects.post
>As you all have I'm writing a script to upload files from a web browser
^^^^^^^^^^^^^^^
>to a web site.
You seem to have a skewed view of what Perl is used for.
Such a statement may be true in some newsgroup related to WWW
things, but this is not such a newsgroup.
>Yes, I've stumble across all the common problems
>(binmode)
That is not a _common_ problem, as binmode does not matter
on many many (most?) web servers.
>The problem
>seems to be in the file reading system, when I read the file supplied by
>
>the user the script seems to read more bytes than the number actually
^^^^^^^^
>available in the file.
Why guess?
read() has a return value that would be useful for detecting
when you haven't read the number of bytes that you tried
to read, but you are not making use of it:
while ( my $size = read ($file, $buffer, 10000)) {
if ( !eof($file) and $size != 10000 ) {
warn "wrong number of bytes read for '$buffer'\n";
}
...
>$onnum = 1;
>while ($onnum != 11) {
foreach my $onnum ( 1..10 ) { # much easier to understand
> my $file = $req->param("FILE$onnum");
> if ($file ne "") {
> my $fileName = $file;
> $fileName =~ s!^.*(\\|\/)!!;
> open (OUTFILE, ">F:/www/mysite/$user/$fileName") || print "<br><b>$0
>ERROR: $!</b><br>";
I don't see where you are untainting the filename.
Is it possible that you do not have taint checking enabled?
That would be Really Bad. All forms-processing CGI programs
should enable taint checking. The world is full of Bad Guys.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 06 Jan 2001 11:35:07 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no binmode!) (repost)
Message-Id: <m3d7e03ah0.fsf@mumonkan.sunstarsys.com>
tadmc@metronet.com (Tad McClellan) writes:
> Patrick Holthuizen <pholthuizen@celwood.com> wrote:
>
> > my $file = $req->param("FILE$onnum");
> > if ($file ne "") {
> > my $fileName = $file;
> > $fileName =~ s!^.*(\\|\/)!!;
I've seen this bad idiom in cgi scripts before;
does anyone know where it originates from?
> > open (OUTFILE, ">F:/www/mysite/$user/$fileName") || print "<br><b>$0
> >ERROR: $!</b><br>";
>
>
> I don't see where you are untainting the filename.
>
> Is it possible that you do not have taint checking enabled?
>
Which confirms to a large degree that people here don't
help those that won't help themselves. I considered
answering the original before, but passed for this
very reason.
--
Joe Schaefer
------------------------------
Date: Sat, 06 Jan 2001 18:02:20 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no binmode!) (repost)
Message-Id: <3a575dac.133$2b3@news.op.net>
In article <slrn95e7gj.ri8.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>Why guess?
He isn't guessing. Note:
while (read ($file, $buffer, 10000)) {
$teller = $teller + length($buffer);
print OUTFILE $buffer;
}
print "File no. $onnum ($fileName) has been transfered. ($teller bytes)<p>\n";
>I don't see where you are untainting the filename.
That would be this line here:
>> $fileName =~ s!^.*(\\|\/)!!;
It's not designed to work specifically with the tainting mechanism,
but it serves the same purpose.
--
@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: Sat, 06 Jan 2001 18:03:48 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no binmode!) (repost)
Message-Id: <3a575e03.139$260@news.op.net>
In article <m3d7e03ah0.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>> > if ($file ne "") {
>> > my $fileName = $file;
>> > $fileName =~ s!^.*(\\|\/)!!;
>
>I've seen this bad idiom in cgi scripts before;
What's bad about it? I don't know much about windows systems, but on
Unix it would be safe.
--
@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: Sat, 06 Jan 2001 18:13:27 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no binmode!) (repost)
Message-Id: <3a576046.183$f4@news.op.net>
In article <3A570E49.989CF625@celwood.com>,
>when I read the file supplied by the user the script seems to read
>more bytes than the number actually available in the file. These
>bytes seem to be occuring at random places within the file.
I think the crucial piece of information that is missing is what bytes
are being inserted and where they are being inserted. Without this
information, I don't think there is much chance of figuring out what
is happening.
I will hazard a guess: The 'count' you did prior to uploading is
incorrect. You are using a character counting program that counts the
"\r\n" sequence as a single character instead of as two characters.
But when you read the data in the CGI program, you have 'binmode'
enabled, so "\r\n" is correctly counted as two characters instead of
as one. have you tried downloading the uploaded file and comparing it
side-by-side with the original, using the same method for both?
Perhaps you don't have any real problem at all.
>The file I try to read is 9277 bytes long but the variable $teller
>contains the value 9314 after reading the file???
I suggest that you try to find a smaller, simpler test case---say, a
file that is 14 bytes long that expands to 15 after you upload it.
Then it will be easy to see what character is inserted. This may
provide a clue to what is going on.
Possibly the browser is inserting a character prior to the upload, or
possibly there is a bug in CGI.pm. Another possibility is that there
is a bug in you: The code you showed that counts the number of
characters received looks good. But you never showed how you were
counting the characters prior to upload; perhaps this is erroneous.
>Any help is appreciated. Mail me if you want the binaries involved, I'm
>unable to attach them to this newsgroup.
In general, it is much more useful to put them on your web site and
post the URL. Then anyone who wants to investigate can do it
immediately. You want to make it as easy as possible for people to
help you.
--
@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: 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 6
************************************