[6984] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 609 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 13 22:07:44 1997

Date: Fri, 13 Jun 97 19:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 13 Jun 1997     Volume: 8 Number: 609

Today's topics:
     Re: "Large Files" <rootbeer@teleport.com>
     Dynamic SELECT using CGI.PM <Craig.gibson@cas.honeywell.com>
     Re: Help with Perl print statement <bricr01@execpc.com>
     Re: How do i convert a (float) to (integer) ? (Honza Pazdziora)
     Re: LOCALTIME & GMTIME functions.... anyone ever use th (rthomas)
     None (Chris Fogarty)
     Perl to awk translator <martin.roeth@mail.heyde.de>
     Re: problem with oo new operations <zenin@best.com>
     Re: security question <rootbeer@teleport.com>
     Re: Tie Scalar ?? <zenin@best.com>
     Re: Un-taint a variable how? <grantt@gribbles.com.au>
     Writing a secure server < port 1024 <MoNoLiTH+@CMU.EDU>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Jun 1997 13:32:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Pillans <jpillan@indiana.edu>
Subject: Re: "Large Files"
Message-Id: <Pine.GSO.3.96.970612133152.17120N-100000@kelly.teleport.com>

On Thu, 12 Jun 1997, John Pillans wrote:

> I would like to know if anyone has been able to get Perl to write files
> larger than 2^^30-1?  

If your system supports it but you can't get perl 5.004 to do it, you
should run perlbug to submit a bug report. Thanks!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 12 Jun 1997 13:02:57 -0700
From: Craig Gibson <Craig.gibson@cas.honeywell.com>
Subject: Dynamic SELECT using CGI.PM
Message-Id: <33A055F1.391E@cas.honeywell.com>

What's the best way to do the following:

A form reads in a list of items from a file.
Assume items are separated by carriage returns, whatever.
An array is set to the items from the file.
The array is passed into the popup_memo.  

So if this list changes, (it's expected to), then there's no need
to change the form. 

I have not yet used CGI.PM, except to run a demo simple example, and
I'm a little confused on the exact syntax, or point me to examples I
missed. (And because all the examples I've seen so far could of been 
done with the standard html SELECT method.)

(As with any new thing I do, it takes me a while to 'get' it.)

Here's how I would start coding the above scheme:

  %elements = &readFile($colorsFileName);
  popup_menu(-name=>'color',
             -values=>%elements);


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

Date: Thu, 12 Jun 1997 15:19:07 -0500
From: Colleen <bricr01@execpc.com>
Subject: Re: Help with Perl print statement
Message-Id: <33A059BB.6FAC@execpc.com>

Colleen wrote:
> 
> i am trying to run a perl5 script and running into some problems.  i am
> getting:
> 
> Can't find string terminator "END_PRINT" anywhere before EOF at
> register.cgi line 72.
> 
> here is the section of the script that's having the problem:
> 
> sub no_name
> {
> print <<"END_PRINT";
> <HTML><HEAD><TITLE>Form Incomplete</TITLE></HEAD>
> <BODY>
> <H1>Form Incomplete</H1>
> I'm sorry, the form was not filled completely.<br>
> Please Return to the form and fill it out completely.<p>
> Thank you.
> <HR>
> #         <a href=\"$referer\">Return to the registration page</a>
> </BODY></HTML>
> END_PRINT
> 
> exit;
> }
> 
> the funny thing about my problem is that i have other scripts that
> compile/run just fine.  i have tryed to cut/paste the statements from my
> other scripts that work, but, end up with the same error message.
> 
> please email me at bricr01@execpc.com with your solution.  i REALLY
> appreciate any help you can provide....colleen




My problem HAS been solved.  Thanks to Dave W. for his solution.  The
solution turned out to be something I never thought/knew about.

I use a Win95 text editor to create scripts.  The Win95 CRLF never got
converted to UNIX LF when I uploaded.  Dave told me to:

	tr -d '\015' <oldfile>newfile
	perl -cw newfile

That solved the puzzle.  I now know to save the scripts in UNIX format
before uploading them.

A special thanks goes out to Dave W., however, I really appreciate all
the responses I received from this group.  Keep up the good work guys. 
I now know where to turn for answers.

Thanks again......colleen


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

Date: Fri, 13 Jun 1997 12:59:31 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How do i convert a (float) to (integer) ?
Message-Id: <adelton.866206771@aisa.fi.muni.cz>

Jonas Thvrnvall <labah@algonet.se> writes:

> Hello!
> 
> A silly question maybe, but however how do i convert $random, it's a
> floating point to an integer?

int($random) if you just want to truncate, sprintf("%.0f", $random) if
you need to round it.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
     Have you done your DES today? --> http://www.des.sollentuna.se/


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

Date: Fri, 13 Jun 1997 15:47:20 GMT
From: rthomas9@worldnet.att.net (rthomas)
Subject: Re: LOCALTIME & GMTIME functions.... anyone ever use these?? - datetime (1/1)
Message-Id: <5nrq0s$e79@mtinsc03.worldnet.att.net>

Sorry about the mess above.

I'm trying to capture the date and time my perl script is executed by users 
of my website.  Here's what I've tried so far.

  1. $dt = time;  which should return the number of seconds since 1/1/70

  2. $dt = gmtime(time);
     $dt = gmtime;        both should use the value of time above to return
                          the current Greewich Mean Time and date.

  3. $dt = localtime;     should return local time and date.

1,2 and 3 return results as expected when I run them on my desktop under
WEBSITE with perl.
When I run the exact same script from my WEB Host's server I get the 
following results.

  1.  a large number (which I assume is the correct number of seconds)

  2.  a null result
      a null result
 
  3.  a null result

My WEB Host tells me he's running Perl 5 but can't offer much else.  I suspect
the gmtime and localtime functions are not loaded with his Perl .  When I run
my script through his interpreter my syntax checks OK.  I'm really quessing at
this point.

Any ideas on how to get a date and time?  Is there an environmental 
variable(s) for this?

Thank you very much for taking the time to help me!

Best,
R. Thomas



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

Date: Fri, 13 Jun 1997 19:44:13 -0400
From: ctf@faithquest.com (Chris Fogarty)
Subject: None
Message-Id: <v03102802afc78b8a07d3@205.199.35.136>

The following is a library and a form script, but they do not work, and I
 cannot for the life of me figure out what the problem is. The Form does not
 seem to get the array from the library. Can someone help? If someone can
 help, could you also email me an answer directly to ctf@faithquest.com


 Christopher Fogarty


 This is the forms-lib.pl

 ++++++++++++++++++++++++++++

 #!/usr/sbin/perl

 sub GetFormInput {
 	local (%input);
 	$input = &ReadInput();
 	%input = &ParseInput($input) if $input;
 return (%input);
 }

 sub ReadInput {
 	local ($method, $input, $length);
 	$method = $ENV{'REQUEST_METHOD'};
 if ($method eq 'GET') {
 	$input = $ENV{'QUERY_STRING'};
 }
 elsif ($method eq 'POST') {
 	$length = $ENV{'CONTENT_LENGTH'};
 	read(STDIN, $input, $length);
 }
 return($input);
 }

 sub ParseInput {
 	local($input) = @_;
 	local(@pairs);
 	@pairs = split('&', $input);
 	foreach $pair (@pairs) {
 		$pair =~ s/\+/ /g;
 		($key, $value) = split('=', $pair, 2);
 		$key =~ s/%(..)/pack("c",hex($1))/ge;
 		$value =~ s/%(..)/pack("c",hex($1))/ge;
 		$input{$key} .="\n" if defined($input{$key});
 		$input{key} .= $value;
 }
 return(%input);
 }
 return 1;

 +++++++++++++++++++++++++++++++++++

 This is the form

 +++++++++++++++++++++++++++++++++++

 #!/usr/sbin/perl

 require('forms-lib.pl');

 %input = &GetFormInput();

 $recipient = $input{'address'} || "ctf\@the-machine.com";
 $message = $input{'comments'}; || "did not work"
 $sender = $ENV{'HTTP_FROM'} || "ctf\@the-machine.com";

 $MAILER = "/usr/lib/sendmail";

 open(MAIL, "|$MAILER -f$sender $recipient");
 print MAIL "To: $recipient\n";
 print MAIL "Subject: Comments on your web site\n";
 print MAIL "\n";
 print MAIL $message;
 close(MAIL);

 print "Content-type: text/html\n\n";
 print <<"EndOfMessage";
 <HTML>
 <HEAD>
 <TITLE> Site Comments</TITLE>
 </HEAD>
 <BODY>
 <H1> Your Comments Were Sent</H1>
 <PRE>
 To: $recipient
 Subject: Comments on your Web Site
 $message
 </PRE>
 EndOfMessage


 ++++++++++++++++++++++++++++++++++++++++++

 and this is the html file

 ++++++++++++++++++++++++++++++++++++++++++

 <HTML>
 <HEAD>
 <TITLE> FeedBack</TITLE>
 </HEAD>
 <BODY BGCOLOR=WHITE>
 <FORM  ACTION="http://www.protos-inc.com/cgi/form.pl">

 Please enter Email Address:
 <br>
 <strong>
 E-Mail:
 </strong>
 <input type="text" name="address" Size=30 maxlength=50>
 <p> Your Comments:
 <br>
 <textarea name="comments" rows=8 cols=50>
 </textarea
 <p>
 <input type="submit" value="Send Comments">
 </FORM>
 </BODY
 </HTML>




----- End Included Message -----





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

Date: Fri, 13 Jun 1997 15:32:54 +0200
From: Martin Rvth <martin.roeth@mail.heyde.de>
Subject: Perl to awk translator
Message-Id: <33A14C06.63CA@heyde.de>

Hello,

I'm looking for an easy method to translate perl scripts to awk. I know
about the a2p translator, but is there something like a p2a translator.

Thanks 
  MR


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

Date: 12 Jun 1997 20:33:44 GMT
From: Zenin <zenin@best.com>
Subject: Re: problem with oo new operations
Message-Id: <5npmf8$j6d$1@nntp2.ba.best.com>

[posted & mailed]

Curtis Hrischuk <ceh@arcturus.sce.carleton.ca> wrote:
> Hi.  Could someone explain to me why the following code executes
> differently for CASE (1) and CASE (2).  
> - With only one item in the hash table CASE 1 works but CASE 2) fails.
> - With two items in the hash table CASE 2 works but CASE 1 fails.
	>snip<
> $anode1 = new ActivityNode(DATA =>$val);
> $anode2 = new ActivityNode(DATA =>$val, MOREDATA => $val2);
	>snip<
>   my %params = @_;
>   my %params = %{$_[0]};		# <=== Different here
	>snip<

	Your first version expects a hash as it's argument.  Your second one
	expects a referance to a hash.  eg:

	CASE 1 wants:
		$Obj = new ActivityNote (DATA => $val);
	CASE 2 wants:
		$Obj = new ActivityNote ( { DATA => $val, MOREDATA => $val2 } );
	or you could do it:
		%Foo = (DATA => $val, MOREDATA => $val2);
		$Obj = new ActivityNote ( \%Foo );

-- 
-Zenin
 zenin@best.com


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

Date: Thu, 12 Jun 1997 13:35:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: brz@hotmail.com
Subject: Re: security question
Message-Id: <Pine.GSO.3.96.970612133445.17120O-100000@kelly.teleport.com>

On Thu, 12 Jun 1997 brz@hotmail.com wrote:

> i've seen people talking about security especially concerning the
> use of internet... (setuid scripts etc...) can someone give me
> a pointer where i can start learning about these?

As for Perl security, see perlsec(1). For general Unix security, try the
UNIX FAQ. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Jun 1997 01:46:52 GMT
From: Zenin <zenin@best.com>
Subject: Re: Tie Scalar ??
Message-Id: <5nq8qc$24d$1@nntp2.ba.best.com>

Tom Phoenix <rootbeer@teleport.com> wrote:
> On 11 Jun 1997, David Tauzell wrote:
> > I would like to create a tied scalar that can return an array if
> > used in array context.
> I don't think scalars can do that. But you might be able to make a tied
> array that acts like a scalar in a scalar context, so that might do what
> you want. Hope this helps!

	I don't think tied arrays can do that. -More likely perl would
	simply return the number of elements it was given, just like
	an array.

	You could get around it by using the object returned to get to other
	methods.  Something like:

	$Obj = tie $Scalar, "MyScalar";

	@Array = $Obj->list;
	$Foo   = $Scalar;

-- 
-Zenin
 zenin@best.com


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

Date: Sat, 14 Jun 1997 09:26:45 +0930
From: "Grant Turrill" <grantt@gribbles.com.au>
Subject: Re: Un-taint a variable how?
Message-Id: <5nsns9$k88@news.planet.net.au>

Hi Ben,

We run some suid scripts to do various system admin stuff such
as resume print jobs, cancel, .. etc. Here is an lp cancel job we use.

#! /var/bin/perl                                   
                                                   
$ENV{PATH} = "/usr/bin";                           
unless (defined ($ARGV[0]) && defined ($ARGV[1]))  
{                                                  
   die "Usage: lp_cancel <printer> <job number>\n";
}                                                  
                                                   
$ARGV[0] =~ /^(\w+)$/;    # <---  Untaint first value                      
  
$printer = $1;                                     
$ARGV[1] =~ /^(\w+)$/;      # <--- Untaint second value                    
   
$job = $1;                                         
$sys_cmd = sprintf("cancel %s-%s", $printer, $job);
exec "$sys_cmd";                                   

We then run this through the suidscript program found in the first
Camel book. The untainting occurs at the lines marked.
This works very well for us on a multi-user system to allow us to 
cancel print jobs without going into super-user all the time.

Regards, Grant


 Ben Neil Gerdemann wrote in article <5nnvvd$if2$1@joe.rice.edu>...
>Hello,
>
>We are running a setuid script and have need to un-taint a variable. How
>is this possible?
>
>Thanks,
>Ben
> 




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

Date: Thu, 12 Jun 1997 16:18:02 -0400
From: Aveek Datta <MoNoLiTH+@CMU.EDU>
Subject: Writing a secure server < port 1024
Message-Id: <Inc5Zua00iVG05xHk0@andrew.cmu.edu>

We're trying to write a secure server under < 1024, so basically we want a
server which has to run as root since its listening to a privileged port,
but after tying IN to STDIN and OUT to STDOUT, spawns another program as
another regular user.

The question is -- how do we setuid in Perl, safely? And if anyone has a
code example for a server which does this safely, I'd appreciate it.

Thanks.

  Network Administrator, Monolith Internet Services [TM]  _ _ _   _  Aveek
  SysAdmin, Carnegie Mellon Univ ITC   _ __  ___ _ _  ___| (_) |_| |_Datta
  Personal Website @ datta.ml.org    _| '  \/ _ \ ' \/ _ \ | |  _| ' \ _
  Get a free domain @ www.ml.org    (_)_|_|_\___/_||_\___/_|_|\__|_||_(_)
    # All opinions are ONLY mine. # Quake'n'Linux'n'Perl'n'MSQL RULE.



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

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

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