[7696] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1322 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 15 14:17:11 1997

Date: Sat, 15 Nov 97 11:00:39 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 15 Nov 1997     Volume: 8 Number: 1322

Today's topics:
     Re: ./[script.pl] not working <webmaster@fccj.cc.fl.us>
     Re: Can't fetch from Altavista with "url_get" (by Jack  (Henry Churchyard)
     CGI PERL SCRIPT to TAR? (John Armsby)
     Re: CGI PERL SCRIPT to TAR? <nospam@domain.com>
     Re: Debugging CGI programs <joseph@5sigma.com>
     Re: Easily using databases - am I reinventing a wheel? (Peter J. Schoenster)
     Re: how do you execute external programs with perl <joseph@5sigma.com>
     Re: how do you execute external programs with perl <tobias@spurv.td.org.uit.no>
     On the fly GIF and CGI <frederic@xilinx.com>
     Re: On the fly GIF and CGI <friedman@uci.edu>
     Re: On the fly GIF and CGI <markm@nortel.ca>
     Opinions please (and maybe help) <mindmore@mindless.com>
     Re: problem with Telnet module (Todd M. Wilkinson)
     Re: Redirecting filehandle to multiple filehandles <westxga@ptsc.slg.eds.com>
     Re: Socket.so problem under Solaris 2.5.1 (Casper H.S. Dik - Network Security Engineer)
     Re: Standard PERL dist under Win95? (Michael Rubenstein)
     Re: Stop CGI program when STOP button in WebBrouser is  <joseph@5sigma.com>
     Strange errors with a "}" <jdubchak@sprint.ca>
     Re: Strange errors with a "}" (Tad McClellan)
     Re: Taint checking problem - insecure PATH <dbenhur@egames.com>
     The importance of binaries and installation (was: Pytho (Cameron Laird)
     using or vs || <sehughes@mistral.co.uk>
     Re: using or vs || <zenin@best.com>
     Re: using or vs || (Eric Bohlman)
     Re: write daemon with Perl (Peter J. Schoenster)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 14 Nov 1997 17:12:11 -0500
From: "Bill Jones" <webmaster@fccj.cc.fl.us>
Subject: Re: ./[script.pl] not working
Message-Id: <346ccd96.0@usenet.fccj.cc.fl.us>

Hmmm...  How about this at the beginning of each perl script:

#!/usr/local/bin/perl -w
#(or where ever you've installed perl...)

Also, you should check to make sure your environment knows where perl is,
IE. 'type perl'

If all is cool, then './script.pl' should execute fine from command line OR
from cgi-bin
(assuming, again, your server is setup correctly...)

Hope this was helpful,
Bill

PS - The #!/usr/bin stuff are shell scripts, which BTW can be used as CGI;
after all, that's what the Common Gateway Interface was defined as - Common
:-)  If you are still having trouble, I am available and can check it out
for you, my fee is normally $600/day, one day minimum.


Radix wrote in message <346AABB2.25C0@freemail.c3.hu>...
>Hello ppl,
>
>I would like to have our web server run perl scripts using cgi on a
>machine with sun solaris 2.6. Still, the script doesnt seem to work. Its
>is placed in the cgi-bin dir. There are sample scripts coming with the
>web server software [sun ws], however, they are not perl scripts,
>instead something like this:
>#!/usr/bin
>echo "hello world"
>
>They can be run from the shell with ./[script].
>
>I have perl installed on the machine, so in the shell i can do:
>perl [script.pl]
>It runs the script. Still, i cant run it from ./[script.pl]. As I
>understand it would be needed to implement perl scripts on the web
>server.
>
>Any help appreciated, thanks.
>
>Radix




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

Date: 14 Nov 1997 22:59:44 -0600
From: churchh@uts.cc.utexas.edu (Henry Churchyard)
Subject: Re: Can't fetch from Altavista with "url_get" (by Jack Lund)?
Message-Id: <64ja80$8si@moe.cc.utexas.edu>

In article <Pine.SGI.3.96.971114120550.9471A-100000@ccs.sogang.ac.kr>,
K MIN  <s941046@ccs.sogang.ac.kr> wrote:

[...]

Your problem is not with the Perl program, but with the shell; since
you didn't quote or escape the URL in any way, the shell interpreted
the "?" character as a request for filename wildcard expansion, and
each "&" character as separating commands to be run in the background.
And in fact, the shell never even called the Perl program at all!  You
should surround the URL with single right quote characters (') on the
shell command line.


--%!PS-Adobe
10 10 scale/M{rmoveto}def/R{rlineto}def 12 45 moveto 0 5 R 4 -1 M 5.5 0 R
currentpoint 3 sub 3 90 0 arcn 0 -6 R 7.54 10.28 M 2.7067 -9.28 R -5.6333
2 setlinewidth 0 R 9.8867 8 M 7 0 R 0 -9 R -6 4 M 0 -4 R stroke showpage
       % Henry Churchyard      http://uts.cc.utexas.edu/~churchh/


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

Date: Sat, 15 Nov 1997 13:22:55 GMT
From: jaws@atl.mindspring.com (John Armsby)
Subject: CGI PERL SCRIPT to TAR?
Message-Id: <64k81t$c6u@camel12.mindspring.com>

We need to provide an "idiots" gui to tar and compress files and
directories.  It is simple enough to write a Perl script to enable the
user to "browse" to a file via Netscape (content type =files...), copy
a file to a directory, and then jump out of the script to unix and
gzip the file.

My problem is How do I get the browser to select directories and then
tar recursively down the tree, finally gzipping the resulting file?  I
don't see any nifty tools in the Perl tool box to enable directory
selection for a subsequent tar.

Any suggestions?

John Armsby john.w.armsby-jr@boeing.com






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

Date: Sat, 15 Nov 1997 15:24:24 GMT
From: John Nolan <nospam@domain.com>
Subject: Re: CGI PERL SCRIPT to TAR?
Message-Id: <346DBF56.3EF5@domain.com>

John Armsby wrote:
> 
> We need to provide an "idiots" gui to tar and compress files and
> directories.  It is simple enough to write a Perl script to enable the
> user to "browse" to a file via Netscape (content type =files...), copy
> a file to a directory, and then jump out of the script to unix and
> gzip the file.

Maybe you can use WinZIP ?
 
> My problem is How do I get the browser to select directories and then
> tar recursively down the tree, finally gzipping the resulting file?  I
> don't see any nifty tools in the Perl tool box to enable directory
> selection for a subsequent tar.

tar recurses by default.  (Have you ever actually used tar?)
Some versions of tar will gzip on the fly if you use
the -z switch.  "tar -cvzf mydirectory.tgz mydirectory",
or something similar.  

You might want to consider using a special ftp server for this
purpose.  The wuftp daemon will automatically tar and gzip
a raw directory tree for you, on the fly, if you request it as
"mydirectory.tar.gz" rather than "mydirectory". 

http://www.sgi.com/TasteOfDT/public/freeware1.0/fw_wuftp/wuftp.html

BTW an idiot succeeds in tarring, compressing, and downloading,
what happens next?  Just curious.  

-John Nolan


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

Date: Sat, 15 Nov 1997 00:33:38 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Debugging CGI programs
Message-Id: <346D5023.A2215414@5sigma.com>

Navid S Kamali wrote:
> 
> Hi I'm fairly new to Perl.
> I was wondering how i can print the value of variable into standard
> output instead of into a web page. My perl programs uses cgi.
> I want to be able to do something like:
> print $variable;  (for debugging purposes)

Get the CGI module (that's what it's called, and it's part of
the 5.004 distribution) and learn to run your program from the command
line.  Also you might want to check out Lincoln's book.

	-joseph


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

Date: Sat, 15 Nov 1997 13:29:10 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Re: Easily using databases - am I reinventing a wheel?
Message-Id: <346da090.56035394@news.magibox.net>

Zenin <zenin@best.com> wrote:

>Peter J. Schoenster <pschon@baste.magibox.net> wrote:
>: I have to make this simple for someone else to administer.  I do not
>: use mSQL or other types although I am looking at them. I find it much
>: easier to write my own dbm or flat-file databases. 
>
>	If multiple people could ever be using this at the same time,

Yeah I would use the lock that doesn't lock (according to everyone -
it just sort of advises and does not prevent a 100% lock).  This as
just for my own use while testing.


>	The main advantages with a SQL database (IMHO) is misc column
>	searches.  Right now you've got them all together as a pipe
>	delimited string in a DBM file.  What this meens is that if you
>	want to search on anything but the DBM key, you're reading the
>	*entire* DBM file, and doing a split() on *every* row of data.
>	If you want column substring searches (show me everything that
>	column "name" starts with "rocky") it gets even worse.  You'll
>	end up with a system that doesn't scale at _all_, since it will
>	slow down at an exponential rate to the number of rows you add.

It just so happens that the movie site I am working on above I need
not search for anything in those rows.  I just do lookups in the dbm
to get personal data about someone.  I do an "agrep" on a directory
which contains the comments people left.  The file name for their
commnet is the key in the dbm so I open the dbm and get their personal
details to stick in the results.  

This is a major reason why I use text files when I need to search on
text.  I search the whole file with "agrep" and then I break the
results down according to column and then extract what was searched
for (like find weight where state==TN and bird==eagle. I am not
searching and splitting every row.  I once got a 24 meg database and
broke it down into 50 separate files  (changed delimiter to pipes and
that saved a lot of space).  It works pretty fast.  A competing
company uses some grand sql program and theirs is a joke by
comparison.  I had to change the date because it came off a mainframe
in 7 or 8 digits (yeah, sometimes a month had 1 or 2 digits; real
odd).  Getting the proper date was a piece of cake with Perl.

Who knows what the "Database" is doing to get results.  My primary
concern is database integrity.  From all I have read there is no
guarantee of real LOCKING.  If the mSQL, for example, could guarantee
that I could put the database on the web and thus be available to
mulitple users at the same time and yet not corrupt the database and
yet record all changes then that in itself is excellent.

About the searching.  I am used to find exactly what I want or close
do it (where I choose how close I want to be).  Can I do this with any
other databases?  I have seen so many examples of forms which seem so
limited.  Is this the limitation of the programmer or the database I
wonder.  

What do you use for databases?

Peter















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

Date: Sat, 15 Nov 1997 00:42:04 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: how do you execute external programs with perl
Message-Id: <346D521C.C568C371@5sigma.com>

Mike Stok wrote:
> 
> In article <346B1876.7B07@swansea.ac.uk>,
> Dean Parratt  <eeparrad@swansea.ac.uk> wrote:
> >I am trying to execute a program or command which has arguments from a
> >loop within a perl program so that the command will execute over and
> >over again. I have tried exec and system but I can't make them execute
> >my command. Can anybody tell me how to do this?
> 
> Well system is probably what you want, could you post the code that fails
> and any error diagnostics?

I can see how exec probably isn't the right approach:

  for (;;) {
    exec 'echo please do this more than once'
  }

heh.

	-joseph


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

Date: 15 Nov 1997 15:28:51 +0100
From: Tobias Brox <tobias@spurv.td.org.uit.no>
Subject: Re: how do you execute external programs with perl
Message-Id: <xn63eky44f0.fsf@spurv.td.org.uit.no>

"Joseph N. Hall" <joseph@5sigma.com> writes:

> I can see how exec probably isn't the right approach:
> 
>   for (;;) {
>     exec 'echo please do this more than once'
>   }

while (1) {
	print 'please do this more than once\n'; # I think you can use echo in perl, at least print.
}

while (1) {
	print `echo please do this more than once`; # backticks executes a command, and returns the stdout output from the command
}

while (1) {
	system("echo please do this more than once"); # system also executes a system command
}

You should also take a look at "spawn" and "exec" at the perlop man
page, but remember you can only start programs in this way, not parse
shell commands. exec never returns, I think.

-- 
Tobias Brox - tobix@abex.no - http://www.cs.uit.no/~tobias


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

Date: Fri, 14 Nov 1997 14:45:04 +0000
From: Frederic RIVOALLON <frederic@xilinx.com>
Subject: On the fly GIF and CGI
Message-Id: <346C63F0.9391D9A1@xilinx.com>



Hello everybody,

  I'm using the gd.pm module to dynamically create a GIF file.  Once
this file is created I can't print it on the screen through my cgi-bin.

  Here an exemple of the code I'm using

 use CGI ':standard';
 use GD;

 $im = new GD::Image(50,50);
 .
 ..
# Draw image
 .
 ..
$temp = $im->gif;
print "<img src=$temp alt=\"temp\" >";


The last print of the program does not print a GIF in my HTML browser
instead it print tons of funky characters
Anybody an idea (I already read the perl faq)

Thank in advance
Frederic
frederic@xilinx.com



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

Date: 15 Nov 1997 17:57:40 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: On the fly GIF and CGI
Message-Id: <64knqk$9d1@news.service.uci.edu>

[mailed, posted]

In article <346C63F0.9391D9A1@xilinx.com>,
Frederic RIVOALLON  <frederic@xilinx.com> wrote:

<  I'm using the gd.pm module to dynamically create a GIF file.  Once
<this file is created I can't print it on the screen through my cgi-bin.
<
<  Here an exemple of the code I'm using
<
< use CGI ':standard';
< use GD;
<
< $im = new GD::Image(50,50);
<$temp = $im->gif;
<print "<img src=$temp alt=\"temp\" >";

When web browsers parse HTML, they open a new connection for each
in-line image.  If you think about it, it's obvious why this has
to be done:  images can come from any host, not just the one where
the document originates.

What you've done is to put the contents of your gif datastream into
the HTML document, where it can't possibly get handled properly.

What you need to do is write a separate script that returns the proper
MIME header (Content-type: image/gif) and then your gif data.  Your
HTML-printing cgi script will then output a URL which references the
gif-printing cgi script so that your clients can look it up.

For example:

<img src="/cgi-bin/printgif?h=50&w=50&" alt="foobar">

You can pass in arguments to your printgif script in QUERY_STRING, so
printgif could be written to handle various kinds of requests.
You may want to check HTTP_REFERER in printgif to reduce the ease
with which people can abuse your system.

Eric

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: 15 Nov 1997 12:46:37 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: On the fly GIF and CGI
Message-Id: <lq17maat5he.fsf@bmers2e5.nortel.ca>

You didn't read the help that came with GD though. As i remember it,
$im->gif results in the BODY of the gif.

    It's either:
         Content-type: text/html

         <html><head><title>...</title></head><body>
         ...
         <img src=URL alt=TEXT>
         ...
         </body>

    Or:
         Content-type: image/gif

         GIF BODY

If you just want to show a picture (no html text) you do:

      use CGI ':standard';
      use GD;
      $im = new GD::Image(50,50);
      ...
      # Draw image
      ...
      print "Content-type: image/gif\r\n\r\n";
      print $im->gif;

hoping this helps,
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Sat, 15 Nov 1997 17:31:47 +0100
From: Nathan|Fain <mindmore@mindless.com>
Subject: Opinions please (and maybe help)
Message-Id: <346DCE72.1C9A9606@mindless.com>

This is a multi-part message in MIME format.
--------------EE540873213DEDF84160D70F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am very new to perl and CGI so I am coming to you all to see what
would be best to do in a project I am doing.

(the project:)
I am putting on the web a catalog. This catalog seems to be problematic
for what I am wanting to do. I am trying to create a CGI script that
reads my Database file (catalog.db, I am still creating the format of
the Tables and Cells in this file) and creates the page for that
product.

(the problems I see).
The problem is that every Product in the catalog has a differing number
of variables needed and is different in the way it is printed to the
browser.

As of now the only thing I know to do is to build a separate file for
each of the differing products of which will contain subroutines for
printing out the unique page for that product (the main script will
check to see what product it needs to print and then require the
appropriate subroutine file for the product and then runs those
subroutines).

Is there any easier way to do this (remember... I'm a new comer to
Perl)?


I'm having trouble getting the Newsgroup into Netscape 4.0 so if you
could, please send your reply to my e-mail ( mindmore@mindless.com ).
THanks

- Nathan Fain
mindmore@mindless.com



--------------EE540873213DEDF84160D70F
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Nathan Fain
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Nathan Fain
n:              Fain;Nathan
org:            Gesher Labs
adr:            3412 Hawthorne Ave, Richmond Va. 23222  USA;;71 Shabtia Hanegbi (apt # 13);Jerusalem;;;ISrael
email;internet: mindmore@mindless.com
tel;home:       917.2.676.0960
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------EE540873213DEDF84160D70F--



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

Date: Sat, 15 Nov 1997 11:27:37 GMT
From: tmwilkin@syr.dont.edu.spam.me.here (Todd M. Wilkinson)
Subject: Re: problem with Telnet module
Message-Id: <346e8635.177839790@news.appliedtheory.com>

On 13 Nov 1997 08:10:37 -0500, Tim Gray
<tim@hcirisc.cs.binghamton.edu> wrote:

>Hi there,
>	I am trying to use the Telnet.pm module on a system where I
>don't have root and therefore can't actually install the module
>properly.  So I put the module in the same directory as my script.  I
>have tried to 'use' it several ways but none work.
>
>use Net::Telnet		#no shock there since it isn't in $PERL5LIB/Net
>use Telnet;
>use Telnet ();
>
>No matter what it "can't locate object method new vie package Telnet".
>
>The code snippet that instantiates the Telnet object looks like this
>
>$popbox = new Telnet (Host => "mail.binghamton.edu",
>                   Port => 110);
>
>Any suggestions?  Thanks.



Try adding a library directory for all of you coustom modules
such as /usr/home/userid/lib/perl/  then add it to have your perl
program find the directory add this.


use lib "/usr/home/userid/lib/perl";


At that point you put all of your files in there such as Telnet.pm or
your Net directory in which Telnet.pm can be found (as in the case 
of "use Net::Telnet;"


-Todd Wilkinson
-tmwilkin@syr.dont.edu.spam.me.here 
-If you really need to send me mail I think you can find me.


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

Date: Fri, 14 Nov 1997 15:24:56 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: Redirecting filehandle to multiple filehandles
Message-Id: <346C6D48.41A4@ptsc.slg.eds.com>

Jamie O'Shaughnessy wrote:
> 
> I'm writing a script to control software testing, as part of the script we
> output everything to the screen and also to a log file. The script calls a
> number of external commands. The problem I have is when I call an external
> command and pipe it's output back into the script (so I can write to both the
> screen and log file), I can't capture the STDERR of the command

[ code snipped]

> The FAQ says to redirect STDERR, e.g.
> 
> open(STDERR, ">&LOG");
> open(CMD, "$cmd |") || die "blah";
> while(<CMD>) {
>    print STDOUT $_;
>    print LOG $_;
> }
> 
> which does redirect the STDERR output of $cmd to the log file, but not to the
> screen.
> 
> Is there any way I can capture the STDERR from the $cmd so I can output it to
> two filehandles, or even act on what I read from STDERR?

Sure, but it ain't straight-forward.

use Symbol;
use IPC::Open3;
$RDR=gensym();
$WTR=gensym();
$ERR=gensym();
$pid=open3($RDR, $WTR, $ERR, "ls", "xxxxx");
while (<$RDR>) {
	print "Output: $_\n";
	}
while (<$ERR>) {
	print "Err: $_\n";
	}

where ls is my command and xxxxx is the argument.


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

Date: 15 Nov 1997 17:10:40 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Socket.so problem under Solaris 2.5.1
Message-Id: <casper.879614256@uk-usenet.uk.sun.com>

[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

Oscar Cwajbaum <oscarc@imsa.edu> writes:


>After upgrading a Solaris 2.5.1 system from perl 5.004_03 to 5.004_04, I 
>starting getting the following error message when using the Socket module:

>Can't load '/usr/local/encap/perl500404/lib/sun4-solaris/5.00404/auto/Socket/
>Socket.so' for module Socket: ld.so.1: /usr/local/bin/perl: fatal: relocation
>error: file /usr/local/encap/perl500404/lib/sun4-solaris/5.00404/auto/
>Socket/Socket.so: symbol __inet_ntoa: referenced symbol not found at 
>/usr/local/encap/perl500404/lib/sun4-solaris/5.00404/DynaLoader.pm line 166.

>If I replace the Socket.so file compiled during the 5.004_04 install with
>the old Socket.so from 5.004_03, the error goes away. 


Lookslike you've installed some for of bind or so eitehr in /usr/include
o rin some place where perl could find it?

Perl will only compile and link fine with the original SOlaris includes.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: Fri, 14 Nov 1997 23:26:19 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Standard PERL dist under Win95?
Message-Id: <346dddd9.181626755@nntp.ix.netcom.com>

On Fri, 14 Nov 1997 07:24:10 -0700, Dan Baker <dtbaker@flash.net>
wrote:

>sysadmin wrote:
>> 
>> I, too, have wondered about this.  While I am currently happy running the
>>  MKS 5.004.03 version of PERL on Win95
>---------
>Have you found the 5004.04 version anywhere? sounds like there were good
>bug fixes in it... I don't have any way to compile, so I need to find
>the binaries. Please post the full URL if you find them!
>
>Also,if you have any information on how to extract from the tar.gz
>files, it would be helpful.... will winzip work on win95, or do I need
>something else?
>
>
>
>> I do NOT want binaries from ActiveState, etc as the greatest aspect of PERL
>>  is its ability to remove my reliance on third-party suppliers.  Give me
>>  the source anyday.
>---------
>I don't mind the binaries... a long as they are free;) But I'd like to
>get the latest. Does the build 313 from activestate correspond to
>5.004.04, or what?

No, it's still at 5.003.07

Michael M Rubenstein


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

Date: Sat, 15 Nov 1997 00:37:09 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Stop CGI program when STOP button in WebBrouser is downed
Message-Id: <346D50F5.A146D4E8@5sigma.com>

The only way you can even hope to get a CGI program to stop
through a browser action is if it is a NPH (non parsed header)
script, in which case the browser is actually socketed more
or less directly to the script.  Otherwise, forget it, since
the script is talking to the server, not the browser.

My experience is that sometimes clicking stop will send a
broken pipe signal to a NPH script, but sometimes it won't.
So there's no reliable answer as far as I know.

	-joseph

p.s. wrong newsgroup for CGI questions


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

Date: Sat, 15 Nov 1997 09:10:12 -0600
From: "John Dubchak" <jdubchak@sprint.ca>
Subject: Strange errors with a "}"
Message-Id: <64kdqa$2cee@top.MTS.Net>

Hi,

I am trying to run the following simple program example but cannot get it to
work.

#!/usr/bin/perl

print("New dir name? ");
chomp($where = <STDIN>);
If (mkdir $where, 0777) {
   print("Successful!\n");
  } else {                            # error occurs here at the }
   print("Unsuccessful.");
}

Syntactically I can't see anything wrong with this.  But it gives me the
same error in Unix, Win32 and DOS versions of Perl.

What gives?

Thanks,
John Dubchak





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

Date: Sat, 15 Nov 1997 09:10:41 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Strange errors with a "}"
Message-Id: <h1ek46.nr5.ln@localhost>

John Dubchak (jdubchak@sprint.ca) wrote:

: I am trying to run the following simple program example but cannot get it to
: work.

: #!/usr/bin/perl


ALWAYS use the -w switch.

   #!/usr/bin/perl -w


: print("New dir name? ");
: chomp($where = <STDIN>);
: If (mkdir $where, 0777) {
  ^^
  ^^
:    print("Successful!\n");
:   } else {                            # error occurs here at the }
:    print("Unsuccessful.");
: }

: Syntactically I can't see anything wrong with this.  But it gives me the
: same error in Unix, Win32 and DOS versions of Perl.

: What gives?


Perl is case sensitive.

"If" is not a keyword.

"if" is a keyword.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 14 Nov 1997 19:56:43 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Ernest Mueller <ernestm@towery.com>
Subject: Re: Taint checking problem - insecure PATH
Message-Id: <346D1D7B.54B@egames.com>

[mail&post]
Ernest Mueller wrote:
> I don't really need all those PATHs, that's just the default PATH on my system.
> My point is that the PATH is *already* set by the system to "/usr/bin...", and
> that can be proven by printing it out in the script.

The fact that it was set by "the system" before perl was invoked in no
way assures perl or your program that the path is secure.

> However, for some reason
> tainting is making me define the path explicitly in the script, at least when I
> run it as a CGI (running it from the command line generates no such problem).

This is expected and desired behavior.  It should happen for commandline
execution too with -T set.

> Certainly this isn't behaving as designed.  I could fix it by declaring a PATH
> in each of my hundreds of CGI scripts I'm changing over to taint checking, but
> I'd rather not.

No, if you bother to understand the security issues you rather WOULD.
Do all your 100s of CGI programs execute other programs thru system(),
backticks, etc.?  You only need to worry about the PATH if your program
isn't self contained.

Go read this:
<URL:http://www.perl.com/CPAN-local/doc/manual/html/pod/perlsec.html#Cleaning_Up_Your_Path>

Actually you should read that whole manpage, but this section
specifically addresses the path issues.

--
Devin Ben-Hur     <dbenhur@egames.com>
eGames.com, Inc.  http://www.egames.com/  The Ultimate Game Store
"Dark is the suede that mows like a harvest" -- Martian Ambassador



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

Date: 15 Nov 1997 11:53:52 -0600
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: The importance of binaries and installation (was: Python is a mini C?)
Message-Id: <64knjg$230$1@Starbase.NeoSoft.COM>

In article <64isrd$plv$1@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> chides me:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.python, 
>    claird@Starbase.NeoSoft.COM (Cameron Laird) writes:
>:1.  Anyone can install Python on a Win* or
>:    MacOS machine.  
>
>I guess you've never looked at http://www.perl.com/CPAN/ports/
>for the mac/ and win32/ subdirectories.
			.
			.
			.
I have (surely you know that about me, Tom; you've read the article
where I called CPAN "the model for other languages").  I couldn't
figure it out.

More precisely, I picked up such binaries as <URL:
http://www.perl.com/CPAN-local/ports/winNT/ActiveState/Release/Pw32s312.exe>
and <URL:
http://www.perl.com/CPAN-local/ports/winNT/Perl5/Release/Pw32s312.zip>,
and installed them uneventfully.  I didn't have problems.  I *was*
puzzled, though, because I never did notice the install.bat and
install.txt promised by <URL:
http://www.perl.com/CPAN-local/ports/winNT/FAQ/PerlFaq.html>.
That's what I was expressing in the post from which you excerpted
the sentence above:  Python and Tcl have installers that I propose
feel more familiar and less threatening to the Win* crowd.

Maybe I missed something obvious, 'cause I already know how I want
my WinNT box set up.  Maybe the FAQ needs a couple of words changed.
Maybe I just happened to check during a glitch, and caught CPAN with
its installations or documentation muddled.  Maybe the only people
confused by two missing files are the members of my own family.  Maybe
using InstallShield doesn't really matter, anyway.  In any case, thanks
for affording me the opportunity to elaborate on a point I clearly
didn't communicate adequately on my first pass.
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 713 996 8546 FAX


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

Date: Fri, 14 Nov 1997 20:09:06 -0800
From: Stuart Hughes <sehughes@mistral.co.uk>
Subject: using or vs ||
Message-Id: <346D2061.639F@mistral.co.uk>

In the script below, if I use the '||' operator to provide a default,
all is okay, but if I change it to 'or' I get an error/warning about the
useless use of a contant in a void context.  I understand that 'or' is
lower precedence than '||' but I would have expected the result to be
the same.  Can anyone explain what is happening.

Thanks Stuart Hughes

#!/usr/local/bin/perl -w
# parameter passing
sub pchk
{
   my $var = shift || "default";  # fails if you use 'or' instead of
'||'
   print "var is $var\n";
}
pchk();
pchk("wink");


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

Date: 15 Nov 1997 07:19:15 GMT
From: Zenin <zenin@best.com>
Subject: Re: using or vs ||
Message-Id: <879578519.431968@thrush.omix.com>

[posted & mailed]

Stuart Hughes <sehughes@mistral.co.uk> wrote:
: In the script below, if I use the '||' operator to provide a default,
: all is okay, but if I change it to 'or' I get an error/warning about the
: useless use of a contant in a void context.

	Here is an complete precedence version:

:    my $var = shift || "default";  # fails if you use 'or' instead of '||'

	The "||" version is seen as:
		my $var = (shift(@ARGV) || "default");
	The "or" version has much lower precedence so it does:
		(my $var = shift(@ARGV)) or "default";

	See how the '"default"' now is it's own statement?  This is
	because while "||" binds tighter then "=", "or" does not.
	Now that nothing is receiving it's return value, it's now a
	"contant in a void context".

	If you wanted to use "or", you'd have to force the tighter
	binding:

		my $var = (shift or "default");

-- 
-Zenin
 zenin@best.com


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

Date: Sat, 15 Nov 1997 07:21:00 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: using or vs ||
Message-Id: <ebohlmanEJoF30.3A1@netcom.com>

Stuart Hughes (sehughes@mistral.co.uk) wrote:
: In the script below, if I use the '||' operator to provide a default,
: all is okay, but if I change it to 'or' I get an error/warning about the
: useless use of a contant in a void context.  I understand that 'or' is
: lower precedence than '||' but I would have expected the result to be
: the same.  Can anyone explain what is happening.

It is in fact the precedence that's biting you.

:    my $var = shift || "default";  # fails if you use 'or' instead of

"or" is the lowest-precedence operator in the version that fails, which 
means that it gets parsed as:

(my $var=shift) or "default";

IOW, it's an expression whose value is either the result of the shift (if
it's non-null) or the string "default" (if the result of the shift was
null).  But nothing's done with that value; it's as if you wrote "2+2;". 
Note in particular that $var will *not* be set to "default" if the shift
had a null result; it will be set to the null result instead. 



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

Date: Sat, 15 Nov 1997 12:45:53 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Re: write daemon with Perl
Message-Id: <346d98eb.54078420@news.magibox.net>

Wallace Cheong <WCHEONG@nortel.ca> wrote:

>I am trying to write a daemon program in Perl.  I did a fork and exec
>command in the perl script.  I would like to set the child process
>session id to its process id, so that it becomes the session and group
>leader and detach from any controlling terminal.  I couldn't find the
>equalivant command of setsid in Perl functions.  How can I do that?  
>All I want is that the Perl script running in the background will not
>hangup after I exit from the shell.   I don't want to call the perl
>script through nohup command.  How to do that?

Wallace,

Running daemons is a little beyond my ken but I found the following in
the 1st edition of Programming Perl:

unless (fork) {
	unless (fork) {
		sleep 1 until getppid ==1;
		while (1 >0) {
			my($do_date) = &get_date;
			($date,$ltime) = split(/\|/,$do_date);
			$ltime .= " MDT 1997";
			&from_file;
			sleep 600;
		}
	}
}

Odd that I could not find in the 2nd edition.

BTW, I have used that for about 2 months on my system and it runs fine
(no sysadmns have complained, it has not crashed nor seems to use much
cpu time).



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1322
**************************************

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