[10693] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4284 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 24 14:07:25 1998

Date: Tue, 24 Nov 98 11:02:34 -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           Tue, 24 Nov 1998     Volume: 8 Number: 4284

Today's topics:
        Dangerous Commands (Justin Wilde)
    Re: Dangerous Commands (Martien Verbruggen)
    Re: Dangerous Commands (Erik)
    Re: Dangerous Commands (Ronald J Kimball)
    Re: Dangerous Commands (Ilya Zakharevich)
    Re: Dangerous Commands (brian d foy)
        difficult multi match in reg expr problem (Michael Haertfelder)
    Re: difficult multi match in reg expr problem (Ronald J Kimball)
    Re: Difficult Pattern matching problem in PERL (Ronald J Kimball)
    Re: Difficult Pattern matching problem in PERL <ebohlman@netcom.com>
        Efficiency of infinite loop and sleep (as a replacement (Bradley K. Farrell)
        Grabbing an image from a cgi on another site (J. Kirk)
        hash... <geir_sjurseth@dell.com>
    Re: hash... (Matthew Bafford)
        Help Desk Perl, CGI and HTTP <rifraser@imag.com>
    Re: help me, perl community!! (Andrew M. Langmead)
    Re: HELP!  Newbie needs major help... (Rich)
        Hiding "To:" field <alex@digi-q.com>
        How can I run a shell script on Perl program ? <wtang@flash.net>
    Re: How can I run a shell script on Perl program ? (Tad McClellan)
        How do I print from a CGI program? <tutton@nortel.com>
    Re: How do I print from a CGI program? (Martien Verbruggen)
    Re: How do you pass parameters to Perl script from HTML (Tom McGee)
    Re: How do you pass parameters to Perl script from HTML (brian d foy)
        How send large email list using perl <webmaster@intervid.co.uk>
    Re: How send large email list using perl (Clay Irving)
    Re: How to print a simple character on the screen ? (Ronald J Kimball)
    Re: How to print a simple character on the screen ? (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 23 Nov 1998 17:19:16 -0700
From: jwilde@openskies.com (Justin Wilde)
Subject: Dangerous Commands
Message-Id: <3659FB83.4354E8F4@openskies.com>

Real Perl Men say it's a good practice to always
scan my arguments
for shell metacharacters, then remove them to
effectively protect my code and machine from those
pesky hackers.

Suppose I don't want to, though, because it will
make my simple little script run less
efficiently?  What perl commands / system calls
*MUST* I avoid to maintain security through my
code? I know a few: system(), eval(), piped
open(),  exec().  How extensive is this list?  Any
I missed?

Regards,
        Justin Wilde




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

Date: Tue, 24 Nov 1998 01:52:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Dangerous Commands
Message-Id: <7jo62.72$Jo2.294@nsw.nnrp.telstra.net>

In article <3659FB83.4354E8F4@openskies.com>,
	jwilde@openskies.com (Justin Wilde) writes:

> Suppose I don't want to, though, because it will
> make my simple little script run less
> efficiently?  What perl commands / system calls
> *MUST* I avoid to maintain security through my
> code? I know a few: system(), eval(), piped
> open(),  exec().  How extensive is this list?  Any
> I missed?

Ok. This comes up regularly. You'll find many equivalent posts from me
and others on this subject in this newsgroup.

Shell metacharacters are only dangerous when you invoke a shell. The
solution is simple: Never ever pass a user supplied string to anything
that invokes a shell. Use exec and system with a list argument. Use
sysopen. Use modules for redirected output.

Anything that inherently calls a shell should never be passed a user
supplied string. Anything that _can_ call a shell (like system) should
be invoked in such a way that it doesn't. Don't use glob. Don't use
open with a user supplied string.

Check every single command that you need to use, to see whether it
invokes a shell.

Trying to parse a string for possible shell metacharacters is
dangerous, and hard. Just avoid ever passing them to a shell.

This is an important message. Do not delete.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: 24 Nov 1998 01:29:24 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Dangerous Commands
Message-Id: <73d25k$7k6$1@news.cyberhighway.net>

In article <3659FB83.4354E8F4@openskies.com>,
	jwilde@openskies.com (Justin Wilde) writes:
> Real Perl Men say it's a good practice to always
> scan my arguments
> for shell metacharacters, then remove them to
> effectively protect my code and machine from those
> pesky hackers.
> 
> Suppose I don't want to, though, because it will
> make my simple little script run less
> efficiently?  What perl commands / system calls
> *MUST* I avoid to maintain security through my
> code? I know a few: system(), eval(), piped
> open(),  exec().  How extensive is this list?  Any
> I missed?

There is no way a simple scan of your arguments for allowable characters
is going to slow down your little script at all noticeably, unless you're
running it on an 8088 processor or something.  The simple fact is, when
running a CGI script (and I assume that's what you really mean), you should
ALWAYS check variables passed to you for bad characters.  It's better
to catch it early than to have another part of your script act in
unpredicted ways.

If you are really dead-set against checking your arguments, then don't use
your arguments for any purpose _at all_.  Just leave them alone.  Don't
even read them in.  NEVER trust the user to provide sane arguments.
NEVER trust the user to use the script as it was intended to be used.
ALWAYS check arguments for sanity.  ALWAYS sanitize arguments before
using them in any capacity in your script.  If you're not going to
enforce a policy of keeping arguments within the range of what you expect
to get as an argument, the arguments you get can be considered completely
useless to you, and should just be thrown away.  To do anything else is
bad programming practice, bad karma, and just asking for trouble.

End of lecture.

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
I view the JVM as just another architecture that Perl ought to be ported to.
(That, and the Underwood typewriter...)
             -- Larry Wall in <199808050415.VAA24026@wall.org>


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

Date: Mon, 23 Nov 1998 23:40:41 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Dangerous Commands
Message-Id: <1diywqt.1uarqs71d3z166N@bos-ip-2-212.ziplink.net>

Justin Wilde <jwilde@openskies.com> wrote:

> Suppose I don't want to, though, because it will
> make my simple little script run less
> efficiently?  What perl commands / system calls
> *MUST* I avoid to maintain security through my
> code? I know a few: system(), eval(), piped
> open(),  exec().  How extensive is this list?  Any
> I missed?

Turn taint checking on.  Anything you do that gives a taint error is
unsafe.

#!perl -T

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 24 Nov 1998 05:52:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Dangerous Commands
Message-Id: <73dhik$f6s$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Martien Verbruggen
<mgjv@comdyn.com.au>],
who wrote in article <7jo62.72$Jo2.294@nsw.nnrp.telstra.net>:
> Shell metacharacters are only dangerous when you invoke a shell. The
> solution is simple: Never ever pass a user supplied string to anything
> that invokes a shell. Use exec and system with a list argument. Use
> sysopen. Use modules for redirected output.

You cannot.  Perl is horrible in this respect: you may ask it to do
something, but it will call shell behind your back.

We are still waiting on Larry's verdict on "magic open considered
harmful" discussion from the last fall.  (There were some ideas how to
protect most-frequently used constructs from magic-open.)

Ilya


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

Date: Tue, 24 Nov 1998 01:23:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Dangerous Commands
Message-Id: <comdog-ya02408000R2411980123200001@news.panix.com>

In article <1diywqt.1uarqs71d3z166N@bos-ip-2-212.ziplink.net>, rjk@coos.dartmouth.edu (Ronald J Kimball) posted:

> Turn taint checking on.  Anything you do that gives a taint error is
> unsafe.

although, of course, not everything that is unsafe gives a taint error :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 24 Nov 1998 03:51:00 +0200
From: haert@wharp.rhein-main.de (Michael Haertfelder)
Subject: difficult multi match in reg expr problem
Message-Id: <75SkzVv-ZZB@wharp.rhein-main.de>

Assuming the following:

$line = "blubb = HG TG   JK  ER";
 ...
if ($line =~ /blubb *= *([A-Z][A-Z] +){1,99}/) {
   print "parameters=$1 $2 $3 $4\n"; }

doesn't work. It is matched but the $1, $2,..  are not filled correctly.
I want to assign "HG" to $1, "TG" to $2, "JK" to $3,...
Why not ?

This doesn't work, too:
if ($line =~ /blubb *= *(([A-Z]{2} +){1,99})/ {
   ....

If it would work: Is there a possibility to find out how much $X are  
matched ?

Thanx in advance

Michael




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

Date: Tue, 24 Nov 1998 00:01:16 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: difficult multi match in reg expr problem
Message-Id: <1diz0wh.196e0wswy8782N@bos-ip-2-212.ziplink.net>

Michael Haertfelder <haert@wharp.rhein-main.de> wrote:

> Assuming the following:
> 
> $line = "blubb = HG TG   JK  ER";
> ...
> if ($line =~ /blubb *= *([A-Z][A-Z] +){1,99}/) {
>    print "parameters=$1 $2 $3 $4\n"; }
> 
> doesn't work. It is matched but the $1, $2,..  are not filled correctly.
> I want to assign "HG" to $1, "TG" to $2, "JK" to $3,...
> Why not ?

There is only one pair of capturing parentheses in that regex, so the
only $digit variable that will be set is $1.  It will be set to the last
successful match of ([A-Z][A-Z] +).  It would be nice if you could use
the {n,m} quantifier to fill the other $digit variables, but you can't.

Perhaps you want something like this:

if ($line =~ /blubb *= *((?: +[A-Z][A-Z])+)/) {
  @params = split ' ', $1;
  print "parameters=@params\n";
}

By the way, I moved the ' +' from the end of the regex to the middle.
Otherwise, the parameter 'ER' in your example would be ignored, because
it's not followed by a space.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 23 Nov 1998 23:40:44 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Difficult Pattern matching problem in PERL
Message-Id: <1diywwd.k25c3rcxplriN@bos-ip-2-212.ziplink.net>

Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> wrote:

> So you need to make the match more frugal, e.g.
> 
>     s(/\*[^*]*\*/)()g;
> 
> (I'd use the * closure instead of + because that also
> matches /**/ "smash" comments)

Although that won't match /**********/ "starry" comments.

This is actually an FAQ; see perlfaq6.

P.S.  That's not a 'closure', that's a quantifier.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 24 Nov 1998 05:55:17 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Difficult Pattern matching problem in PERL
Message-Id: <ebohlmanF2wwG5.LE7@netcom.com>

Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
: P.S.  That's not a 'closure', that's a quantifier.  :-)

In PerlSpeak, it is.  In formal language theory, the "Kleene star" is in 
fact a closure.



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

Date: Tue, 24 Nov 1998 17:43:56 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Efficiency of infinite loop and sleep (as a replacement for cron/at)
Message-Id: <365be158.57973955@news.m.iinet.net.au>

Dear cplm'ers

I have been reading and enjoying this ng for the last few weeks, and
have finally summoned the courage to post a question. (My previous
posts were just responses).

Problem: I wanted to use cron/at/batch to do some automated file
renaming, but my ISP will not give users access to these commands.

My solution: I have written a small perl script to do the renaming for
me. It uses an infinite while loop and the sleep function. (Code
follows at end of post).

Next problem: My ISP is reluctant to let users run such scripts
because they feel it will chew up CPU cycles.

Intended solution: I would like to show my ISP that my perl script (or
something similar) is CPU efficient. I therefore seek comment
regarding my code, particularly my choice of the "infinite while with
sleep" construction. eg:

1. is "for(;;)" better then "while()" ?
2. does the sleep function conserve CPU cycles ?
3. is there a better way to do all this ?
   (in this instance I define "better" as "having a lesser impact on
    my ISP" :)

I have already checked: llama, camel, man pages, faq, dejanews; and
hope to hell I haven't missed anything.

Many thanks for your time
Bradley

my script:
--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--
#!/usr/bin/perl -w

use strict;
my ($oldfile, $newfile, $bkf_email);

$oldfile   = '/u/b/bradley/public_html/experiment/file1.shtml';
$newfile   = '/u/b/bradley/public_html/experiment/file2.shtml';
$bkf_email = "bradley\@iinet.net.au";

 
while () {
    if (-e $newfile) {
        rename $oldfile, "$oldfile.backup";
        rename $newfile,  $oldfile;
        Send_Confirmation();
    }
    sleep (24 * 60 * 60);
} #end while


sub Send_Confirmation {

    open(SENDMAIL, "| /usr/bin/sendmail -oi -t -n")
      or die "can't open sendmail _$!_";

    print SENDMAIL <<End_of_Mail;
To: $bkf_email
From: $bkf_email
Reply-To: $bkf_email
Subject: Index files swapped

A new index file has replaced the old index file.
A copy of the old index file has been saved.
End_of_Mail

    close(SENDMAIL) or die "can't close sendmail _$!_";

} #end sub Send_Confirmation
--%<----%<----%<----%<----%<----%<----%<----%<----%<----%<--

-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: Tue, 24 Nov 1998 14:13:18 GMT
From: jdkirk@tfbf.com (J. Kirk)
Subject: Grabbing an image from a cgi on another site
Message-Id: <365abbe7.86963977@news.supernews.com>

I will admit I am new to perl, but I won't admit(I'm ashamed) how many
hours I have researched to find a solution to this, but haven't found
one.  Anyway here is the deal:

There is another site that has a cgi that produces an image.  The site
I might also mention has a userid and password to access it.  I need
to run that cgi from the other site, then display it in a page on my
site along with my html.

I have played with http-lib.pl from S. Sol with no luck ( I don't
think it supported authentication).  I also tried one that used LWP
but my Host does not have those modules installed ( I have also failed
in attempting to install those modules in my home directory).  The
only one I have found to work is a command line program, which I can't
figure out how to call it inside another perl script with out getting
the 500 error.

The host is running Red Hat Linux with Perl 5 installed.

Does anyone have a simple clean cut example of exactly how to do this?
I think Perl is a great language and I love new things, but I'm not a
Perl programmer.


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

Date: Tue, 24 Nov 1998 10:26:44 -0600
From: "Geir Sjurseth" <geir_sjurseth@dell.com>
Subject: hash...
Message-Id: <73em7k$t19$1@obsidian.us.dell.com>

I have an array of associative arrays and I am trying to test against one
element, and it won't work.
My code looks something like this
if ($array[1]{first} eq "whatever")
    {
    blah;
    }
It's always false.  If I print the value of the array it works fine I just
can't test against it.  Anybody out there know why?

Geir




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

Date: Tue, 24 Nov 1998 12:32:18 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: hash...
Message-Id: <MPG.10c4b7af380db32b989732@news.scescape.net>

In article <73em7k$t19$1@obsidian.us.dell.com>, geir_sjurseth@dell.com 
says...
=> I have an array of associative arrays and I am trying to test against one
=> element, and it won't work.
=> My code looks something like this

Something like?  Why not show us actual code?

=> if ($array[1]{first} eq "whatever")
=>     {
=>     blah;
=>     }
=> It's always false.  If I print the value of the array it works fine I just

How did you print it?

Consider:

$_ = 'hello   ';

print "\$_ = $_\n";

Often, it's hard to tell if there are spaces in there (and how many).

Try:

print "\$_ = [$_]\n";

And, if your data has spaces:

print "\$_ = [$_]\n";
print '.' x 60, "\n";

Also:

$_ = "No  \b\bspaces.";
print "\$_ eq [$_]\n";

Prints:

$_ eq [Nospaces.]

which can be misleading...

=> can't test against it.  Anybody out there know why?

HTH!

=> Geir

--Matthew


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

Date: Tue, 24 Nov 1998 17:54:07 +1100
From: Richard Fraser <rifraser@imag.com>
Subject: Help Desk Perl, CGI and HTTP
Message-Id: <365A580E.5C38A6B8@imag.com>

At the risk asking the wrong news group

Is a public domain suite of code, which could be used by a Help Desk, to
log, document and close support calls?
I envisage some perl code, using the cgi calls to create and manage the
data from a varitey of hard ware platforms. I have seen similar using
Louts/Notes, but I am looking for something which runs on SGI/SUN/HP,
with SGI/HP/SUN/PC/NT clients.

Any suggestions

Regards

Richard Fraser



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

Date: Tue, 24 Nov 1998 01:24:29 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: help me, perl community!!
Message-Id: <F2wJwt.C11@world.std.com>

MAConsultants <maconsultants@thelyp.com> writes:

>only, when i transfer the script to the customers ISP's server (an NT
>server) it doesn't work. this is no sendmail vs. windmail thing. the
>script never even gets that far.  i get the following message:

>'D:\inetpub\wwwroot\162117\vjivv4xt\cgi-bin\form.cgi' script produced no
>output

I'm glad your enjoying your forays into programming. If you are the
type that loves constantly learning and discovering new things, it
will probably be a great avocation or vocation.

Its very likely that your problem has nothing to do with perl, per
se. You're going to have to do some digging to find out exactly where
the problem is. Most web servers write out information about events
occuring in the web server in some sort of log mechanism. How you
access this logging is server specific. Your first task should be to
get some documentation about the web server that you are using, and
figure out how to access these logs. If you need some help, there are
a bunch of newsgroups that deal with different types of servers, some
are in the comp.infosystem.www.servers.* hierarchy.

Once you find the logs, you'll find more information from the web
server on what went wrong. A lot of systems seem to tell a small
amount of diagnostic information to the end-user, but tell globs to
the administrator. It kind of makes sense. The end-user doesn't care
*why* it failed, but the support staff should.

The server logs may contain some error or warning messages from the
perl interpreter. The perl package, like all decent software packages
comes with gobs of documentation. This includes the perldiag man page,
a complete listing of all possible messages the compiler may
emit. Because of Perl's Unix heritage, they are often refered to as
"man" pages. Luckily, most of the people involved in porting perl to
various non-unix platforms have made an effort to convert these
documents to a format appropriate for the platform. The OS/2 port has
 .INF files, the Win32 port has .HTML pages, and the Macintosh version
has them availabe from the "Help" menu.

One possible guess on what the error will be is that the file was
transfed via FTP in binary mode instead of text mode. If that is the
problem, then check how to transfer the file the correct way.

By the way. If you created your CGI scripts with the CGI.pm module,
you can test them from the command line without the intervening server
and browser components. This may make debugging a little easier. Check
the "CGI man page for details.

For a quick checklist of common CGI mistakes, you might want to take a
look at the document
<URL:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>.

If you have trouble accessing the perl documentation on your local
machine, there are online versions at
<URL:http://www.perl.com/CPAN-local/doc/manual/html/>

And again, there are newsgroups that are better suited for WWW and CGI
matters in the comp.infosystems.www.* hierarchy. This newsgroup is
more for questions along the lines of "why does perl say xxx, when I
do yyy?", not "why isn't my server executing my script correctly?"

>is anyone out there?

Have you seen the number of messages that get posted here a day? There
is probably to many of us out here.
-- 
Andrew Langmead


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

Date: 24 Nov 1998 00:34:45 GMT
From: richm@ucesucks.mulveyr.roc.servtech.com (Rich)
Subject: Re: HELP!  Newbie needs major help...
Message-Id: <slrn75jvn2.5mv.richm@ll.aa2ys.ampr.org>

On Mon, 23 Nov 1998 16:46:44 GMT, J.Oliver <sabs45@hotmail.com> wrote:
>OK, I'm actually far enough now that all I need is a bit of code that reads
>the subject line out of a text file that contains an email and renames the
>file with that subject line. And the time sent, and the sender.  So
>filename=sender, subject line, time sent.

   So what do you have so far, that you need help with?

- Rich

--
Rich Mulvey                                         
My return address is my last name, 
   followed by my first initial, @mulveyr.roc.servtech.com        
http://mulveyr.roc.servtech.com
Amateur Radio: aa2ys@wb2wxq.#wny.ny.usa


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

Date: Tue, 24 Nov 1998 10:43:15 -0800
From: Alex Guberman <alex@digi-q.com>
Subject: Hiding "To:" field
Message-Id: <3659F287.3025@digi-q.com>

Does anybody know if it's possible to hide "To:" field when sending a
message through mailprog?

Alex


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

Date: 24 Nov 1998 16:29:16 GMT
From: "William Tang" <wtang@flash.net>
Subject: How can I run a shell script on Perl program ?
Message-Id: <01be17c6$08473380$5d68b9a3@wtang-sgl.sugar-land.geco-prakla.slb.com>

Hello,
I have two questions:
1) I try to run a shell script in my Perl program. which is:
source $SMS/path_complete.csh
When I run it in perl (no matter using system, exec or backtick and include
Perl Shell module), it always give me error "no such file or directory". Is
there some way I can run this shell script, or I must rewrite the file
path_complete.csh into Perl ?
(I'm on Unix solaris 2.5.1 using perl 5.004)

2) Also I try to write a perl script to automatically run some commands (C
exe program), and some of them require STDIN inputs during the process. Is
there a way I can redirect the STDIN inputs to the process in my perl
scripts ?

Thanks.


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

Date: Tue, 24 Nov 1998 12:07:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How can I run a shell script on Perl program ?
Message-Id: <klse37.t1k.ln@flash.net>

William Tang (wtang@flash.net) wrote:

: I have two questions:
: 1) I try to run a shell script in my Perl program. which is:
: source $SMS/path_complete.csh
: When I run it in perl (no matter using system, exec or backtick and include
: Perl Shell module), it always give me error "no such file or directory". 


   because they use the Bourne shell, not the csh.

   'source' is spelled '.' in sh

   See also the Perl FAQ, part 8:

      "I {changed directory, modified my environment} in a perl script.  
        How come the change disappeared when I exited the script?  
        How do I get my changes to be visible?"



: 2) Also I try to write a perl script to automatically run some commands (C
: exe program), and some of them require STDIN inputs during the process. Is
: there a way I can redirect the STDIN inputs to the process in my perl
: scripts ?


   perldoc -f open



   # UNTESTED

   open(ECHO, '|echo') || die "could not fork  $!";

   print ECHO 'some text for the STDIN of echo';

   close(ECHO) || die "error writing to 'echo'  $!";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 23 Nov 1998 18:37:53 -0600
From: John Tutton <tutton@nortel.com>
Subject: How do I print from a CGI program?
Message-Id: <3659FFE0.8275162E@nortel.com>

I'd like to send several text documents to the client's printer
from a CGI program.

When printing one document, I can just build an HTML page and
have the user print it with Netscape's Print command, but I'd
like to give the user the ability to print a group documents
without having to print each one seperately from different Web
pages.

Can I emulate the browser's print command from a CGI program?
Is there an environment variable that holds the value of the
client's default printer?

Thanks in advance for your help.

-JT




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

Date: Tue, 24 Nov 1998 01:53:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How do I print from a CGI program?
Message-Id: <Uko62.73$Jo2.294@nsw.nnrp.telstra.net>

[Followups set]

In article <3659FFE0.8275162E@nortel.com>,
	John Tutton <tutton@nortel.com> writes:
> I'd like to send several text documents to the client's printer
> from a CGI program.

You can't. To confirm this and to find out why, please continue the
discussion on comp.infosystems.www.authoring.cgi

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | What's another word for Thesaurus?
NSW, Australia                      | 


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

Date: Tue, 24 Nov 1998 00:36:37 GMT
From: tamcgee@home.com (Tom McGee)
Subject: Re: How do you pass parameters to Perl script from HTML #exec statement?
Message-Id: <tamcgee-2311981937180001@cc1017583-a.union1.nj.home.com>

Actually, it does work.

I scanned the documentation mr. foy pointed to, but I think I'm missing
something. Feel like saving me 15 minutes and giving me a clue?

--Tom

In article <73c2pj$qrm$1@nnrp1.dejanews.com>, dturley@pobox.com wrote:

>>In article <tamcgee-2111981759500001@cc1017583-a.union1.nj.home.com>,
>>  tamcgee@home.com (Tom McGee) wrote:
>>> Why is this a problem?
>>>
>>
>>Because it doesn't work is the first answer that comes to mind.
>>
>>-----------== Posted via Deja News, The Discussion Network ==----------
>>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own


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

Date: Mon, 23 Nov 1998 20:27:46 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do you pass parameters to Perl script from HTML #exec statement?
Message-Id: <comdog-ya02408000R2311982027460001@news.panix.com>

In article <tamcgee-2311981937180001@cc1017583-a.union1.nj.home.com>, tamcgee@home.com (Tom McGee) posted:

> Actually, it does work.

which server?  not Apache like ones.
 
> I scanned the documentation mr. foy pointed to, but I think I'm missing
> something. Feel like saving me 15 minutes and giving me a clue?

the QUERY_STRING (along with the entire enviroment) for SSIs are taken 
from the parent page.  thus, you can't specify it in the include.

had you checked deja news and pondered the docs for longer than 15
minutes, you would have saved yourself a bit of typing.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 24 Nov 1998 12:13:05 -0000
From: "Marcus" <webmaster@intervid.co.uk>
Subject: How send large email list using perl
Message-Id: <73e80m$4ed$1@taliesin.netcom.net.uk>

I have an ascii email list of 4000+ addresses and I need a perl program to
send a mailshot to them all.

Where can I find such a program?

Thanks,

Marcus (webmaster@intervid.co.uk)





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

Date: 24 Nov 1998 08:47:18 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: How send large email list using perl
Message-Id: <73edd6$7uj@panix.com>

In <73e80m$4ed$1@taliesin.netcom.net.uk> "Marcus" <webmaster@intervid.co.uk> writes:

>I have an ascii email list of 4000+ addresses and I need a perl program to
>send a mailshot to them all.

>Where can I find such a program?

-> Perl Reference
   http://reference.perl.com

 -> Perl Reference: mail and USENET news
    http://reference.perl.com/query.cgi?mail

  -> Majordomo
     http://www.greatcircle.com/majordomo/
     Majordomo is a program which automates the management of Internet 
     mailing lists. 

-- 
Clay Irving
clay@panix.com


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

Date: Mon, 23 Nov 1998 23:40:47 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <1diyx66.1awj1841laufj1N@bos-ip-2-212.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> It is not valid Perl with 'use strict;' (ergo, IMO, it is not valid Perl
> -- if one wants symbolic references, one should use 'use strict;' 
> supplemented by 'no strict q(refs);' in the right places).

So that would mean that the following is not valid Perl:

#!perl
$foo = 10;

and neither is this:

perl -pi -e 'foreach(split){$count{$_}++}' \
         -e 'END{foreach(sort keys %count){print "$_\t$count{$_}\n"}}'

even though, without 'use strict;', it
  + compiles,
  + runs, and
  + does something useful.


Your logic stinks.  The validity of a Perl program is not defined by
'use strict;'.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 23 Nov 1998 22:27:53 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <MPG.10c3f1c1b4f0c7b598991f@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <1diyx66.1awj1841laufj1N@bos-ip-2-212.ziplink.net> on Mon, 23 
Nov 1998 23:40:47 -0500, Ronald J Kimball <rjk@coos.dartmouth.edu> 
says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > It is not valid Perl with 'use strict;' (ergo, IMO, it is not valid Perl
> > -- if one wants symbolic references, one should use 'use strict;' 
> > supplemented by 'no strict q(refs);' in the right places).
> 
> So that would mean that the following is not valid Perl:
> 
> #!perl
> $foo = 10;
 ... 
> Your logic stinks.  The validity of a Perl program is not defined by
> 'use strict;'.

Let's not get into a flame war about this.  I was being deliberately 
extremist and you have helped to clarify the narrower point.

Last week there was a thread about symbolic references being needed in 
Perl 5 only for rather obscure and relatively dangerous symbol-table 
manipulations.  This convinces me that the default should be 'use strict 
q(refs);', and that it not being so is the same level of 'bug' as '-w' 
not being the default.

As a reminder, the question seemed to be about

   $letter = \x47;

A compiler (or language, if you wish) that lets that abomination -- 
which misled several subscribers here -- go through *by default* without 
complaining bitterly is seriously deficient ('buggy', IMO).  I do *not* 
think that is (or at least, should be) valid Perl, but I do think that 
this would be:

    { no strict 'refs';  $letter = \x47 }

Extraordinary circumstances should require extraordinary measures.  
Probably the same thing should be said about 'use strict q(subs);'.

OTOH, note that each of your examples (one of which I snipped) deals 
with 'use strict q(vars);' which is a different problem entirely.  I do 
not think that should be the default, because for simple programs (or 
for Benchmark for example) it can be a bloody pain in the ass to have to 
declare every variable.  And backward compatibility would obviate such a 
change in any case.

It is a question of relative utility -- helpfulness to the programmer 
vs. straitjacket for common uses.  I think two out of those three 
defaults are now *wrong* and should be changed, and that there would be 
little repercussion caused by lack of backward compatibility.  I hope 
The Other Larry is listening.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 4284
**************************************

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