[22333] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4554 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 12 06:05:53 2003

Date: Wed, 12 Feb 2003 03: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)

Perl-Users Digest           Wed, 12 Feb 2003     Volume: 10 Number: 4554

Today's topics:
    Re: Accessing remote files in NT (Joe Smith)
    Re: Cannot use additional modules!!?? (Bryan Castillo)
    Re: Cannot use additional modules!!?? <goldbb2@earthlink.net>
        CPSM and CANCEL REQID (DENIS R)
        How to manipulate directories, records, etc... (aleatory)
    Re: How to manipulate directories, records, etc... <spamtrap@nowhere.com>
    Re: How to manipulate directories, records, etc... (Anno Siegel)
    Re: Impossible to do CRLF->LF on Windows/Activestate? <bart.lateur@pandora.be>
    Re: Insecure Filehandle Dependencies (Villy Kruse)
    Re: Insecure Filehandle Dependencies <tassilo.parseval@post.rwth-aachen.de>
    Re: newbie date comparison (Anno Siegel)
        Perl script to create new user in Linux. <kjetil.klove@nrk.no>
        print <<HERE; <istink@real.bad.com>
    Re: print <<HERE; <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Prompt to Save Locally (Joe Smith)
        proxy authenticate with perl problem <ban_krupt@mail.hongkong.com>
    Re: Request help with this script (Jay Tilton)
    Re: Request help with this script <flavell@mail.cern.ch>
        Saving/Editing SQL queries (Guy)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Feb 2003 08:09:53 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Accessing remote files in NT
Message-Id: <ljn2a.3967$io.152926@iad-read.news.verio.net>

In article <d7bdcf6c.0302090704.4e2f12cb@posting.google.com>,
flyershistory <flyershistory@hockeymail.com> wrote:
>I only have access to a certain directory on a web server. I have no
>control over the installation of perl. The @INC file is basically
>empty - and all attempts to get a proper installation done has failed.

Well, just make @INC be non-empty at BEGIN time.

    use lib 'H:/flyer/perl/lib';		# Modern versions of perl
    BEGIN { unshift @INC,'H:/flyer/perl/lib'; }	# Ancient perl

	-Joe
-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 11 Feb 2003 22:04:23 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Cannot use additional modules!!??
Message-Id: <1bff1830.0302112204.548d0e39@posting.google.com>

ibm_97@yahoo.com (JZ) wrote in message news:<10bc841c.0302111512.172b8bc3@posting.google.com>...
> Since default Perl on Solaris 8 doesn't have large file support
> (right?), I compiled and installed my own Perl 5.8 as a non-root user.
> installation is fine. Also I successfully installed DBI and DBD
> modules under the new perl. Everything works cool.
> 
> Now I transferred entire my Perl into another Solaris 8 box, but it's
> in different location. Now my simple testing script (t.pl) doesn't
> work at all:
> 

I'd bet if you looked in the FAQ you would find info about relocating
a perl binary distribution, but I'm too lazy to verify it.  Anyway you
will need to modify Config.pm.  It has directory information stored
within it.  If you want to see what one might do in relocating perl,
check out the "reloc_perl" script in the bin directory of the Active
State distribution.  Basically, you will need to search and replace
your old directory for a new directory.


> #!perl/bin/perl -w
> push(@INC,"/tmp/migration/perllib-sun/");
> use DBI;
> 

(You should really fix you installation, but if you did
 want to add to @INC some other directory.....)

Either of these 3 would work:

  1. push(@INC,"/tmp/migration/perllib-sun/");
     require DBI;

     see perldoc -f require
 

  2. push(@INC,"/tmp/migration/perllib-sun/");
     eval("use DBI;");


     see perldoc -f use


  3. #!perl -I/tmp/migration/perllib-sun
     use DBI;

     see perldoc perlrun


> The error message is :
> Can't locate DBI.pm in @INC (@INC contains:
> /export/home/oracle/migration/perl/lib/5.8.0/sun4-solaris
> /export/home/oracle/migration/perl/lib/5.8.0
> /export/home/oracle/migration/perl/lib/site_perl/5.8.0/sun4-solaris
> /export/home/oracle/migration/perl/lib/site_perl/5.8.0
> /export/home/oracle/migration/perl/lib/site_perl .) at ./t.pl line 2.
> BEGIN failed--compilation aborted at ./t.pl line 2.
> 
> Same error with 'use lib' statement.
> 
> Here is "ls -l /tmp/migration/perllib-sun/":
> 
> drwxr-xr-x   2 oracle   dba          180 Jan 20  2003 Bundle
> drwxr-xr-x   2 oracle   dba          447 Jan 20  2003 DBD
> drwxr-xr-x   4 oracle   dba          990 Jan 20  2003 DBI
> -r--r--r--   1 oracle   dba       207934 Dec  1 17:36 DBI.pm
> -r--r--r--   1 oracle   dba        27606 Aug  6  2001 Oraperl.pm
> drwxr-xr-x   2 oracle   dba          184 Jan 20  2003 Win32
> drwxr-xr-x   4 oracle   dba          237 Jan 20  2003 auto
> -r--r--r--   1 oracle   dba         1292 May  2  2000 oraperl.ph
> -rw-r--r--   1 oracle   dba          525 Jan 20  2003 perllocal.pod
> 
> 
> It contains DBI and DBD modules.
> 
> The thing bothers me is why @INC deesn't have the new value which I
> 'push' into. And it only includes the default values which were get
> from original machine.
> 
> Anything wrong when I configure Perl or installation? I didn't get any
> errors...
> 
> 
> Thanks a lot!!!!


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

Date: Wed, 12 Feb 2003 02:38:39 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Cannot use additional modules!!??
Message-Id: <3E49F9FF.BCFFABDF@earthlink.net>

Bryan Castillo wrote:
[snip]
> > #!perl/bin/perl -w
> > push(@INC,"/tmp/migration/perllib-sun/");
> > use DBI;
[snip]
> Either of these 3 would work:
> 
>   1. push(@INC,"/tmp/migration/perllib-sun/");
>      require DBI;
> 
>      see perldoc -f require
> 
> 
>   2. push(@INC,"/tmp/migration/perllib-sun/");
>      eval("use DBI;");
> 
>      see perldoc -f use
> 
>   3. #!perl -I/tmp/migration/perllib-sun
>      use DBI;
> 
>      see perldoc perlrun

There's also:

   use lib qw(/tmp/migration/perllib-sun);
   use DBI;

Or:

   BEGIN { push @INC, qw(/tmp/migration/perllib-sun) }
   use DBI;

Or:

   BEGIN { unshift @INC, qw(/tmp/migration/perllib-sun) }
   use DBI;

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 12 Feb 2003 02:17:16 -0800
From: raphael.denis.prestataire@cegetel.fr (DENIS R)
Subject: CPSM and CANCEL REQID
Message-Id: <1066b291.0302120217.59bf238d@posting.google.com>

Hi,

Environment
We use CPSM (1.4 with CICS TS 1.30) with one TOR and two AORs and we
observe some problem about the CANCEL of ICE with some transactions
whitch use a REQID.
In the application an ICE is created with a START TRANSID INTERVAL
REQID and before RETURN TRANSID. The ICE is cancelled with the command
CANCEL REQID (PF3 key)before the next START TRANSID INTERVAL REQID.
All the temporary storage created in the AORs are routed in the TOR
but we can see in MAINVIEW a TS named TERMID/TRANSID still stay in a
AOR as the ICE. (This is the name of the REQID.)

Problem
The transaction is OK when the execution is in the same AOR and if
after the RETURN TRANSID the transaction is in the other one AOR, the
TS is unknown for the application.
CANCEL REQID with option SYSID can resolve the problem but not
acceptable for us.

Question ?
Does anybody knows how this CANCEL REQID can be made without the SYSID
option ?
Is it possible to use the WLM of CPSM (TRANGRP) to resolve the problem
?

Best regards,

             Raphaël DENIS


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

Date: 11 Feb 2003 22:26:03 -0800
From: aleatory@hotmail.com (aleatory)
Subject: How to manipulate directories, records, etc...
Message-Id: <a68a4ee0.0302112226.33e3e1b1@posting.google.com>

Hello perl gurus,

I have a few questions I'd like to ask.

I'm asked to write a perl program on the UNIX box.
This box gets SAP-generated ASCII files containing 
order#, serial#, etc at least once a day. My program 
is supposed to find how many order numbers and serial 
numbers get transferred each day.

Here are the questions I'd like to ask:

1. Finding # of directories having the *LATEST DATE*
   How could I find # of directories having the latest
   date? When the UNIX box gets files from SAP, each
   transfer creates a directory on the UNIX machine 
   such as:

	drwxrwxrwx 2 admin admin 1024 Feb 11 00:00 020803sap_transferred
	drwxrwxrwx 2 admin admin 1024 Feb 11 00:05 020903sap_transferred
	drwxrwxrwx 2 admin admin 1024 Feb 11 00:10 021003sap_transferred

2. Finding all the directory names having the *LATEST DATE*
   Since I have to extract records from each transfer 
   file, I need to know all the file names having the latest
   date.

3. Need to extract data only the first 3 fields
   Each SAP transfer file has the same file format such as
   (Each field is delimited by a "|" character.):


	serial#	| order# | customer info1 | customer info2 | etc...

   Currently my program reads in such as 

	#!/usr/bin/perl
	
	$line = "order_no|serial_no|customer_info1|customer_info2";
	@array = split ( /\/, $line );

	$count = 0;
	while ( $count < 4 )
	{
	  print ( "$array[$count]\n" );
	  $count++;
  	}

        I need only the first 3 fields. I don't need
        after the 3rd field. Is there any way to improve
	this code even though it works okay?

I would appreciate your help.

Thanks in advance,

alea


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

Date: Wed, 12 Feb 2003 10:26:51 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: How to manipulate directories, records, etc...
Message-Id: <kv5k4vk7ern69vece25b40iq62vifode5m@4ax.com>

On 11 Feb 2003 22:26:03 -0800, aleatory@hotmail.com (aleatory) wrote:

>Hello perl gurus,
>
>I have a few questions I'd like to ask.
>
>I'm asked to write a perl program on the UNIX box.
>This box gets SAP-generated ASCII files containing 
>order#, serial#, etc at least once a day. My program 
>is supposed to find how many order numbers and serial 
>numbers get transferred each day.
>
>Here are the questions I'd like to ask:
>
>1. Finding # of directories having the *LATEST DATE*
>   How could I find # of directories having the latest
>   date? When the UNIX box gets files from SAP, each
>   transfer creates a directory on the UNIX machine 
>   such as:
>
>	drwxrwxrwx 2 admin admin 1024 Feb 11 00:00 020803sap_transferred
>	drwxrwxrwx 2 admin admin 1024 Feb 11 00:05 020903sap_transferred
>	drwxrwxrwx 2 admin admin 1024 Feb 11 00:10 021003sap_transferred
>

Use the command line :

find . -name "*sap_transferred" -type d -mtime -1 | wc -l

 

>2. Finding all the directory names having the *LATEST DATE*
>   Since I have to extract records from each transfer 
>   file, I need to know all the file names having the latest
>   date.

File::Find ... if you know the date and the format of the directory name
is always as above :

find2perl . -name "*sap_transferred" -type d -mtime -1 > myfind.pl 

>
>3. Need to extract data only the first 3 fields
>   Each SAP transfer file has the same file format such as
>   (Each field is delimited by a "|" character.):
>
>
>	serial#	| order# | customer info1 | customer info2 | etc...
>
>   Currently my program reads in such as 
>
>	#!/usr/bin/perl

No warnings, no strict ... you should use them -- they will save you
endless headaches.
>	
>	$line = "order_no|serial_no|customer_info1|customer_info2";
>	@array = split ( /\/, $line );
>

Is that a typo?  Don't you want to split on '|'?

>	$count = 0;
>	while ( $count < 4 )
>	{
>	  print ( "$array[$count]\n" );
>	  $count++;
>  	}

@array already knows its size, you don't need to subscript.
>
>        I need only the first 3 fields. I don't need
>        after the 3rd field. Is there any way to improve
>	this code even though it works okay?
>


try this :

#!/usr/bin/perl 
use warnings;
use strict;
my $line = "order_no|serial_no|customer_info1|customer_info2";
my ($order_no, $serial_no, $customerinfo, undef) = split /\|/, $line; 
__END__


Assuming you have many such recoreds you may want to introduce a hash or
an array to hold each triple ...

e.g.

my %records;

while (my $line = <DATA>) {
  my ($order_no, $serial_no, $customerinfo, undef) = split /\|/, $line;
  push @{ $records{$order_no} }, ($serial_no, $customerinfo);
}

Now you hace a nice hash of arrays.

use Data::Dumper;
print Dumper(%records);

HTH



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

Date: 12 Feb 2003 10:35:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to manipulate directories, records, etc...
Message-Id: <b2d827$qg1$1@mamenchi.zrz.TU-Berlin.DE>

aleatory <aleatory@hotmail.com> wrote in comp.lang.perl.misc:
> Hello perl gurus,
> 
> I have a few questions I'd like to ask.
> 
> I'm asked to write a perl program on the UNIX box.
> This box gets SAP-generated ASCII files containing 
> order#, serial#, etc at least once a day. My program 
> is supposed to find how many order numbers and serial 
> numbers get transferred each day.

You mean, how many different oder numbers and serial numbers are
mentioned in one set of files?  Your statement isn't entirely clear,
but I'll assume that for now.

> Here are the questions I'd like to ask:
> 
> 1. Finding # of directories having the *LATEST DATE*
>    How could I find # of directories having the latest
>    date? When the UNIX box gets files from SAP, each
>    transfer creates a directory on the UNIX machine 
>    such as:
> 
> 	drwxrwxrwx 2 admin admin 1024 Feb 11 00:00 020803sap_transferred
> 	drwxrwxrwx 2 admin admin 1024 Feb 11 00:05 020903sap_transferred
> 	drwxrwxrwx 2 admin admin 1024 Feb 11 00:10 021003sap_transferred
> 
> 2. Finding all the directory names having the *LATEST DATE*
>    Since I have to extract records from each transfer 
>    file, I need to know all the file names having the latest
>    date.

These two questions amount to the same.

It is usually not a good idea to rely on the change date of directories.
You'd be better off checking only the dates of the actual files.

For a practical approach you'd first have to make explicit what
you mean by "latest date" (or *LATEDT DATE*).  Then you can use
File::Find to select the files that meet the condition.  
Supposing you want to find all the files in a directory $dir that
are newer than the time in $from_time (in seconds since the epoch),
that could look like this:

    use File::Find;

    my $dir = '.';
    my $from_time = time() - 24*60*60;

    my @coll;
    find(
        sub { push @coll, $File::Find::name if
            -f and (stat)[ 9] >= $from_time;
        },
        $dir
    );
    print join "\n", @coll, '';

> 3. Need to extract data only the first 3 fields
>    Each SAP transfer file has the same file format such as
>    (Each field is delimited by a "|" character.):
> 
> 
> 	serial#	| order# | customer info1 | customer info2 | etc...

Are there blanks allowed around the "|"?

> 
>    Currently my program reads in such as 
> 
> 	#!/usr/bin/perl
> 	
> 	$line = "order_no|serial_no|customer_info1|customer_info2";
> 	@array = split ( /\/, $line );
                         ^^^
This doesn't compile, the regex isn't terminated.  Use /\s*\|\s*/.

> 	$count = 0;
> 	while ( $count < 4 )
> 	{
> 	  print ( "$array[$count]\n" );
> 	  $count++;
>   	}
> 
>         I need only the first 3 fields. I don't need
>         after the 3rd field. Is there any way to improve
> 	this code even though it works okay?

It doesn't work (see above).  After fixing it you'd only have to replace
 "4" in the loop condition with "2".  Can't be that hard.

To do the actual counting (untested):

    my ( %order_count, %serial_count);
    @ARGV = @coll;
    while ( <> ) {
        my ( $order, $serial) = split /\s*\|\s*/;
        $order_count{ $order}++;
        $serial_count{ $serial}++;
    }
    while ( my ( $order, $count) = each %order_count ) {
        print "Order number $order appeared $count times\n";
    }
    while ( my ( $serial, $count) = each %serial_count ) {
        print "Serial number $serial appeared $count times\n";
    }


Anno


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

Date: Wed, 12 Feb 2003 10:57:06 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Impossible to do CRLF->LF on Windows/Activestate?
Message-Id: <o3ak4vs30cf3ca3qn5963crgfiats0qgmq@4ax.com>

Kirk Is wrote:

>I thought a one liner like 
>
>perl -e "while($line = <>) { $line =~ /\r$//; print $line; }" < dos.txt > 
>unix.txt
>
>would fix it, but unix.txt is still 14 bytes (and reads as a PC format 
>file to textpad.

Apply binmode() on your output handle, and you *will* get a Unix text
file.

-- 
	Bart.


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

Date: 12 Feb 2003 08:25:57 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Insecure Filehandle Dependencies
Message-Id: <slrnb4k18l.gpe.vek@station02.ohout.pharmapartners.nl>

On 11 Feb 2003 19:06:19 GMT,
    Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:


>Also sprach Alan J. Flavell:
>
>> On Feb 11, Tassilo v. Parseval inscribed on the eternal scroll:
>> 

>> 
>>> -T is actually the source of your problem.
>> 
>> Pardon me, but the underlying source of the "problem" could still be
>> there in the absence of -T, just that it would not be noticed until it
>> was much too late!
>
>Well, naturally. With problem I was referring to the error-message that
>turned out to be unresolvable for the OP and not in the least implying
>that -T should be dropped. That was not the content of my suggestion
>later on.
>


Some readers may never bother to read beyond this point and therefore won't
read the good advice you intended to give.  



Villy


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

Date: 12 Feb 2003 08:48:46 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Insecure Filehandle Dependencies
Message-Id: <b2d1pe$hpt$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Villy Kruse:

> On 11 Feb 2003 19:06:19 GMT,
>     Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> 
>>Also sprach Alan J. Flavell:
>>
>>> On Feb 11, Tassilo v. Parseval inscribed on the eternal scroll:
>>> 
> 
>>> 
>>>> -T is actually the source of your problem.
>>> 
>>> Pardon me, but the underlying source of the "problem" could still be
>>> there in the absence of -T, just that it would not be noticed until it
>>> was much too late!
>>
>>Well, naturally. With problem I was referring to the error-message that
>>turned out to be unresolvable for the OP and not in the least implying
>>that -T should be dropped. That was not the content of my suggestion
>>later on.
>>
> 
> Some readers may never bother to read beyond this point and therefore won't
> read the good advice you intended to give. 

I don't take any responsibility for any mischief caused by odd
reading habits of people. ;-)

But you are right. I didn't even consider this case.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 12 Feb 2003 10:54:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie date comparison
Message-Id: <b2d94f$qg1$2@mamenchi.zrz.TU-Berlin.DE>

Jodyman <Jodyman@hotmail.com> wrote in comp.lang.perl.misc:

[...]

> if ($new_month < 10) { $new_month = "0$new_month"; }
> if ($new_day < 10) { $new_day = "0$new_day"; }
> if ($new_year < 10) { $new_year = "0$new_year"; }

Will this bit of cargo cult never go away?

There is a perfect tool named "sprintf" that formats numbers in every
common way.  Only with date manipulation this clumsy method of tacking
on zeroes seems to be common practice.

    $new_month = sprintf "%02d", $new_month;
    # etc.

or do all three in one go:

    $_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year;

Anno


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

Date: Wed, 12 Feb 2003 11:05:54 +0100
From: "Kjetil" <kjetil.klove@nrk.no>
Subject: Perl script to create new user in Linux.
Message-Id: <D0p2a.27059$Rc7.389130@news2.e.nsc.no>

Hello!

Does anyone have a Perl-script (or a receipt) to make new Linux-users?  I
would really appreciate it if I could have a copy :-) Please send a copy of
answers to my email-adress.  I'm using SUSE 7.3.

Thanks for any answer :-)

Best regards
Kjetil Kløve
Norway




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

Date: Wed, 12 Feb 2003 03:09:22 -0500
From: istink <istink@real.bad.com>
Subject: print <<HERE;
Message-Id: <3E4A0132.312E2971@real.bad.com>

print <<HERE;
will print
this
stuff
up
to
HERE


is this possible?
pseudo code:
$thisthing <<HERE;  (or @thisthing perhaps)
blah
blah
zzzzzzzzzz
HERE

I know it won't work literally.


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

Date: Wed, 12 Feb 2003 08:17:45 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: print <<HERE;
Message-Id: <Xns93205DE7ADDAelhber1lidotechnet@62.89.127.66>

istink wrote:

> print <<HERE;
> will print
> this
> stuff
> up
> to
> HERE
> 
> 
> is this possible?
> pseudo code:
> $thisthing <<HERE;  (or @thisthing perhaps)
> blah
> blah
> zzzzzzzzzz
> HERE



$thisthing = <<HERE;
blah
blah
zzzzzzzzzzz
HERE



For more info perldoc perlop.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Wed, 12 Feb 2003 07:31:45 GMT
From: inwap@inwap.com (Joe Smith)
Subject: Re: Prompt to Save Locally
Message-Id: <BLm2a.3964$io.152926@iad-read.news.verio.net>

In article <b2bos1$1avot5$1@ID-158028.news.dfncis.de>,
ColdCathoids <mememe@meme.com> wrote:
>I have a cgi script that screen scrapes a webpage and formats a table of
>values into a csv. The next step is to prompt the user the contents of the
>string/array as a csv locally on their computer.

I used this:
<A HREF="http://www.tymnet.com/cgi-bin/access.cgi/US-DIALUP.CSV">download</A>.

Your CGI can send either "Content-type: application/octet-stream" or
"Content-type: application/ms-excel" as the MIME type.
	-Joe
-- 
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Wed, 12 Feb 2003 18:43:12 +0800
From: "Ban" <ban_krupt@mail.hongkong.com>
Subject: proxy authenticate with perl problem
Message-Id: <b2d7sj$i81$1@news.ctimail.com>

Dear all,

I am writing a perl script such that I have a database of user:password, I
have to submit to the perl to authenticate the proxy server for login.
I can make a script that can successful return the html after the
authentication back to the webclient.

However, seems that when I continue to click on the returned page,
reauthentication is needed.
I am wondering if I have passed back the cookie to the webclient.

Would there be any sample for me?
Thanks all.

Ban





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

Date: Wed, 12 Feb 2003 10:10:43 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Request help with this script
Message-Id: <3e4a0933.234915868@news.erols.com>

julia4_me@yahoo.com (Julia Briggs) wrote:

: > Do not use this code.  If it is up and running, remove it immediately.
: 
: EEP! Using the above mentioned changes, will it prevent what you are
: speaking of here (running other programs )??

Summarizing and expanding on the changes suggested by others:

1. use warnings;

Mostly a debugging tool, but an invaluable one.  Don't develop code
without it.

2. use strict;

That one deserves the most attention.  The way the program uses
symbolic references creates gaping holes that allow the user to change
a lot of what goes on in the program.

The other thing strict will help is that you'll have to declare the
program's variables, encouraging use of my() instead of local().

The program will need some non-trivial changes to accommodate "use
strict;" and you will probably find it frustrating.  But it will force
changes to exactly the places where the program is most easily
compromised.

3. Put the -T switch on the shebang line.

Forcing taint checks on data encourages the habit of validating all
incoming data before it's used for anything.  You'll have to consider
exactly what data may be considered valid.  It's better to be overly
restrictive than to be overly permissive.

This is tricky.  It's easy to a bad job of laundering tainted data,
and it is not as easy to do it well.  Put perlsec on your must read
list.

4. Check the results of open() and close().

Solid advice for any program, not just one that will run in a CGI
environment.  When those two functions are allowed to silently fail,
you'll go bananas trying to find the problem.

5. Use the "function()" form of subroutine call instead of the
"&function" one.

The "&function" form has some peculiar effects.  Unless you know what
they are and you know you need them, use the "function()" form.  See
perlsub to learn more.

There's also a style issue in that one.  Heavy use of the "&function"
form suggests the program is a relic of the Perl4 era, and the author
hasn't bothered learning anything since.

6. Utilize the methods provided by CGI.pm

for the HTTP response header, at least.  The routine is already loaded
with "use CGI;" , it's easy, and it can provide more flexibility than
simply printing a Content-type.



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

Date: Wed, 12 Feb 2003 11:15:37 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Request help with this script
Message-Id: <Pine.LNX.4.53.0302121110410.7803@lxplus073.cern.ch>

On Feb 11, Julia Briggs inscribed on the eternal scroll:

> EEP! Using the above mentioned changes, will it prevent what you are
> speaking of here (running other programs )??

Where server security is concerned, I couldn't with a clear conscience
recommend half-measures.  When a script is so crass as the one
exhibited here, it's not worth expending more effort to try to fix it,
especially if (no offence meant) you feel that you need to seek advice
about it.

If you want to gateway HTTP to email, you could look at the NMS
scripts for example.  http://nms-cgi.sourceforge.net/

good luck


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

Date: 12 Feb 2003 00:41:57 -0800
From: guymal@hotmail.com (Guy)
Subject: Saving/Editing SQL queries
Message-Id: <8c80bc84.0302120041.528ae3f6@posting.google.com>

Hi,
I'm working on a web application (written in Perl, duh!) that allows users
to execute SQL queries on a relational database (and save/edit these
queries).
Since the users have no knowledge of either the db scheme or SQL, my
application lets them create queries using a web based GUI according to
terms that the users know (an abstraction of the db scheme).

I'm looking for a way to translate a given data structure (that represents
what the user wants in their query) to actual SQL (so I can run it) and to
save this query in order to edit it later.

Here is a typical scenario:
A user creates a query using the GUI, their query is translated into SQL and
executed. The user can save this query (somehow) and edit it later in the
GUI (and then save it again).

Any suggestions/ideas?

TIA,
Guy


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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