Re: Encrypting data on the server

2001-06-26 Thread Mel Matsuoka

At 09:34 PM 06/26/2001 -0700, MRossland wrote:
>Hi all,
>
>Here's my goal: To take information via a form, encrypt it with a duel key
>encryption, and then write that encrypted message to a text file for latter
>use. I also need to do this in such a way so that the server admin's can't
>read it (I work for a credit union, and regulations are stiff).
>
>Do anyone have any advice on how I could go about encrypting the data? I've
>looked at PGP, and the various Perl modules, but the private key is coded
>into the script, and so admin's could get at the data.
>
>I'm not sure that this is even possible :-(

I'm not sure if I'm misunderstanding what you're really trying to do, but
the private-key (in public-key encryption systems like PGP) has nothing to
do with the encryption of the message to the owner of the public-key. You
just have to keep your public-keyring on the server, and just encrypt your
data using that public-key. There's a few PGP modules on CPAN that you
could use to make this easier.

The only time you need the private key is when you need to DE-crypt the
message...and that doesn't involve the server at all, so theres no security
risk. AFAIK, you do have to create a "dummy" private-keyID that corresponds
to the public-key on your server (at least thats the only way I could get
it to work with PGP 2.6.x)

Of course, this doesn't apply if you want to send /signed/ encrypted
messages, as that requires the presence of the private-key during the
encryption phase. 

I run an online store for a conference & seminar recording company
(shameless plug - http://www.vwtapes.com), where we take SSL secured
orders, as well as encrypt the orders & creditcard data on the server end.
The script then emails our ordering department with the same PGP encrypted
order, whereupon they simply decrypt the message right in thier PGP-enabled
mail program. Easy as pie. 

It's so simple that I just cant understand why mega-million dollar
e-commerce sites continue to have credit-card database "hacks" on thier
webservers. If a dorky cheap bastard who works for a mom & pop company like
me can do it, why can't they? We've gone 5 years without a single security
compromise...and looking at my server logs, it's definitely not because the
"script-kiddies" AREN'T trying.

This is all the more amazing, considering that our webstore is based on
Selena Sol's awful, Perl-4 based "Web Store" script :P  (I'm rolling out a
totally revamped and redesigned site, using PHP, so dont laugh at my site
as it is :)

Hope this helps...Aloha,
mel



__
mel matsuokaHawaiian Image Productions
Chief Executive Alphageek  (vox)1.808.531.5474
[EMAIL PROTECTED]  (fax)1.808.526.4040



Encrypting data on the server

2001-06-26 Thread MRossland

Hi all,

Here's my goal: To take information via a form, encrypt it with a duel key
encryption, and then write that encrypted message to a text file for latter
use. I also need to do this in such a way so that the server admin's can't
read it (I work for a credit union, and regulations are stiff).

Do anyone have any advice on how I could go about encrypting the data? I've
looked at PGP, and the various Perl modules, but the private key is coded
into the script, and so admin's could get at the data.

I'm not sure that this is even possible :-(

--Mark Ross.




This may help

2001-06-26 Thread Paul Burkett

I hope this will give you a better understanding of how my script is
running:

#!/usr/bin/perl
use strict;
  use CGI qw/:standard/;
  print header( -status => '204 No Content' );
open(CU, '/usr/bin/cu');
print(CU "-s 9600 /dev/term/a\n");
close(CU);

open(DEV, '>>/dev/term/a') or die "Couldn't open serial device:$!\n";
{my $prevh = select DEV; $|=1; select $prevh;
}

# enter the serial port where the camera
# device is located here

print "Perl LABCAM console - Please insert what camera you would like to
view or the amount of cameras you would like to see on screen: \n";

$camera=;
if ($camera==1){
print "You chose camera $camera\n";
print(DEV "@"),
select ( undef, undef, undef, 0.09 ),
print(DEV "0"),
select ( undef, undef, undef, 0.09 ),
print(DEV "1"),
select ( undef, undef, undef, 0.09 );
}


- Does anything seem not right? Is there a way to make it redirect to the
same page?




RE: CGI Return

2001-06-26 Thread Paul Burkett

Odd, it still gives me "500..." but now this time the script wont work.

-Original Message-
From: Curtis Poe [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 25, 2001 12:59 PM
To: CGI Beginners
Subject: RE: CGI Return


--- Paul Burkett <[EMAIL PROTECTED]> wrote:
> I'm running Solaris 7, it is a security camera system where you can choose
> certain cameras to be displayed on the internet. It uses a JavaPush cam
> plugin to display what the cameras are viewing. Basically I have it set up
> (I wrote the script in perl) that if you click on say Button "1" it will
> POST it to the script and the script will send print(DEV, "@01"). DEV is
the
> serial device term/a (ttya). It works but it goes to another webpage
saying
> "500 Internal Server Error" I heard that I need to enter "Content-type:
> text/html" but I don't know where.

In a CGI script, any data that is printed to STDOUT goes to the Web server
which in turn sends
this data to the browser.  "Content-type: text/html\n\n" is typically the
last line of the headers
and comes *before* your script prints out anything to the body of the
document.  Since the Web
server typically supplies the majority of the headers for your Web page, you
usually just need to
print the content type and then print anything else that you need after
that.  The CGI.pm header()
function does that for you (text/html) is the default:

  #!/usr/bin/perl -wT
  use strict;
  use CGI qw/:standard/;
  print header();
  # anything else printed comes *after* the header()

> Also I heard that there is an HTTP
> command called 204 that won't redirect the script to another page. You can
> see the webpage @ www.atglab.org just click on "Lab Cam" towards the upper
> right hand corner.

204 is an HTTP status code (sent in the headers) that a script can send
saying that everything
went fine, but there is no need to update the page.  I've typically seen
this used in Web pages
that have Javascript auto-submit form data in the background and let's the
user continue reading
the page.

  #!/usr/bin/perl -wT
  use strict;
  use CGI qw/:standard/;
  print header( -status => '204 No Content' );
  # Don't print anything else with this status code

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/




500 Internal Server Error

2001-06-26 Thread Paul Burkett

Everything I try I get the same error! I've tried using 'use CGI' but still
nothing. I found a command that works it's called "HTTP Command 204" but how
do I implement this into the script? And where do I put the "Content:" line
in?




Re: Hashes and hashes of hashes

2001-06-26 Thread Randal L. Schwartz

> "Philip" == Philip Peeters <[EMAIL PROTECTED]> writes:

Philip>   %newdata = ();
Philip>   $newdata{$TAG} = $co->param('account');
Philip>   $newdata{$TAG}[0] = $co->param('initsearch');
Philip>   $newdata{$TAG}[1] = $co->param('team');
Philip>   $newdata{$TAG}[2] = $co->param('website');

That can't work.  You can't have $newdata{$TAG} simultaneously
be a data value *and* an arrayref.

That first one might need to be $newdata{$TAG}[0] then instead.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: Hashes and hashes of hashes

2001-06-26 Thread Curtis Poe

--- Philip Peeters <[EMAIL PROTECTED]> wrote:
>   %newdata = ();
>   $newdata{$TAG} = $co->param('account');
>   $newdata{$TAG}[initsearch] = $co->param('initsearch');
>   $newdata{$TAG}[team] = $co->param('team');
>   $newdata{$TAG}[website] = $co->param('website');

There are a couple of problems here.  First:

$newdata{$TAG} = $co->param('account');

You're assiging a scalar value to $newdata{$TAG}, but then:

$newdata{$TAG}[initsearch] = $co->param('initsearch');

You want curly braces {} instead of the square braces [] (curly indicates a hash, the 
square
indicates an array).  However, even that doesn't solve the problem because now you're 
trying to
use $newdata{$TAG} as a ref to an anonymous hash when you've previously assigned a 
scalar to it. 
You'll wipe out the scalar value.  Here's my guess as to what you want:
#!/usr/bin/perl -wT
use strict;
use CGI;
use Data::Dumper;

my $co = CGI->new;

my %newdata;
my $tag = 'test';

my @form_elements = qw/ account initsearch team website /;
my @temp_values;

foreach my $element ( @form_elements ) {
$newdata{ $tag }{ $element } = $co->param( $element );
}
print Dumper \%newdata;

When called from the command line with the following:

   ./test.pl account=test initsearch=first team=alpha website=perlmonks

It will print the following data structure:

$VAR1 = {
  'test' => {
  'initsearch' => 'first',
  'account' => 'test',
  'team' => 'alpha',
  'website' => 'perlmonks'
}
};

Then, to access the 'account' data for $tag, you use this:

my $data = $newdata{$tag}{'account'};

Hope that helps!

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Hashes and hashes of hashes

2001-06-26 Thread Casey West

On Tue, Jun 26, 2001 at 04:32:35PM -0700, Philip Peeters wrote:
: When my script is called, I parse in some variables. I want to build
: a hash where the one variable will function as the a key of the hash
: and the other variables must be referenced by again a reference.. Confused?
: Me too. Example:
: 
:   %newdata = ();
:   $newdata{$TAG} = $co->param('account');
:   $newdata{$TAG}[0] = $co->param('initsearch');
:   $newdata{$TAG}[1] = $co->param('team');
:   $newdata{$TAG}[2] = $co->param('website');
: 
: should become:
: 
:   %newdata = ();
:   $newdata{$TAG} = $co->param('account');
:   $newdata{$TAG}[initsearch] = $co->param('initsearch');
:   $newdata{$TAG}[team] = $co->param('team');
:   $newdata{$TAG}[website] = $co->param('website');
: 
: But I can't seem to get this to work. Is this just a syntax problem,
: or is something more fundamentally wrong?

This is a syntax problem.  Try the following:

  $newdata{$TAG}{initsearch} = $co->param('initsearch');
  [...]

and access them with the same structure.

  Casey West

-- 
Shooting yourself in the foot with Postscript 
foot bullets 6 locate loadgun aim gun shoot showpage 



Hashes and hashes of hashes

2001-06-26 Thread Philip Peeters

Hi,

First of all thanks for the references to the Storables module to dump
a hash/array into a file so other cgi's can use this hash/array too.
It works great!

But I ran into another issue (I think it's just a syntax issue, but I'm
not sure I'm appraoching this correctly):

When my script is called, I parse in some variables. I want to build
a hash where the one variable will function as the a key of the hash
and the other variables must be referenced by again a reference.. Confused?
Me too. Example:

  %newdata = ();
  $newdata{$TAG} = $co->param('account');
  $newdata{$TAG}[0] = $co->param('initsearch');
  $newdata{$TAG}[1] = $co->param('team');
  $newdata{$TAG}[2] = $co->param('website');

should become:

  %newdata = ();
  $newdata{$TAG} = $co->param('account');
  $newdata{$TAG}[initsearch] = $co->param('initsearch');
  $newdata{$TAG}[team] = $co->param('team');
  $newdata{$TAG}[website] = $co->param('website');

But I can't seem to get this to work. Is this just a syntax problem,
or is something more fundamentally wrong?

Thanks in advance,
Philip

___
To get your own FREE ZDNet Onebox - FREE voicemail, email, and fax,
all in one place - sign up today at http://www.zdnetonebox.com




Re: It WORKS!

2001-06-26 Thread Curtis Poe

--- Paul Burkett <[EMAIL PROTECTED]> wrote:
> wow the darn thing works! Hey Ovid, is it ok if I add your name to the list
> of contributers to my script? I'll also let you look at the script if you
> want toohell I'll let you see it in action at my website if you want to!
> 
> The lines that i needed were:
> 
> my $q = CGI->new("");
> 
> print $q->header(-type=>'text/html',
> -status=>'204 No Response');
> 
> That's it! Wow my first real program at 16...I feel special!

Huh?  Frankly, I'm astonished that my suggestions helped.  I was just guessing as to 
what the
issues may have been.

Yes, you may add my name to the list.  I never object to having my name being more 
widely known
... never know when I'll be job hunting again :)

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



It WORKS!

2001-06-26 Thread Paul Burkett

wow the darn thing works! Hey Ovid, is it ok if I add your name to the list
of contributers to my script? I'll also let you look at the script if you
want toohell I'll let you see it in action at my website if you want to!

The lines that i needed were:

my $q = CGI->new("");

print $q->header(-type=>'text/html',
-status=>'204 No Response');

That's it! Wow my first real program at 16...I feel special!

-Original Message-
From: Curtis Poe [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 2:22 PM
To: CGI Beginners
Subject: Re: CGI...blea


--- Paul Burkett <[EMAIL PROTECTED]> wrote:
> Ok, this is odd, I got it so it wont redirect the webpage, but now it
won't
> change the camera. When I restore it to the original code it changes the
> camera but redirects the page to "500 Internet Server Error." Shouldn't
> STDIN work in CGI scripts?

The 500 error is an error that your Web server is returning.  It means that
the output of the
script is not as expected.  First, check your error logs.  These should give
you an idea of what
the actual problem is (if the program is not compiling, for example).  It
could also be some sort
of buffering issue where output is being sent to STDOUT before the headers
have been sent.  This
is a particularly insidious problem if you are calling external programs
with "system" or
backticks.  Read http://perl.plover.com/FAQs/Buffering.html for more
information.

If it's a buffering issue with a CGI script, include this at the top of the
script:

$|++;

That should disable buffering for STDOUT.

As for STDIN, that depends upon what you are doing there.  Remember that
POST data from a form is
sent to and read from STDIN.  When you first instantiate a CGI object (or
make certain function
calls when using the function-oriented interface), then CGI.pm might read
the contents of STDIN,
as this is where it often expects to find form data.  If you have an
external program sending data
to STDIN, you may be having problems with CGI.pm clobbering the data (to be
fair, this will happen
with virtually any CGI parsing code).

If an external program is writing to STDIN, can you pipe the data somewhere
else and read it from
there?

Another tactic:  if you are using CGI.pm but are not using the form-handling
code, then tell
CGI.pm to take its data from another source.  One way is to do this:

  my $q = CGI->new("");

Then, you can use $q at will without clobbering STDIN.  This is often used
for debugging when you
want consistent query parameters:

  my $q = CGI->new('color=red&name=Ovid');

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/




Re: CGI...blea

2001-06-26 Thread Curtis Poe

--- Paul Burkett <[EMAIL PROTECTED]> wrote:
> Ok, this is odd, I got it so it wont redirect the webpage, but now it won't
> change the camera. When I restore it to the original code it changes the
> camera but redirects the page to "500 Internet Server Error." Shouldn't
> STDIN work in CGI scripts?

The 500 error is an error that your Web server is returning.  It means that the output 
of the
script is not as expected.  First, check your error logs.  These should give you an 
idea of what
the actual problem is (if the program is not compiling, for example).  It could also 
be some sort
of buffering issue where output is being sent to STDOUT before the headers have been 
sent.  This
is a particularly insidious problem if you are calling external programs with "system" 
or
backticks.  Read http://perl.plover.com/FAQs/Buffering.html for more information.

If it's a buffering issue with a CGI script, include this at the top of the script:

$|++;

That should disable buffering for STDOUT.

As for STDIN, that depends upon what you are doing there.  Remember that POST data 
from a form is
sent to and read from STDIN.  When you first instantiate a CGI object (or make certain 
function
calls when using the function-oriented interface), then CGI.pm might read the contents 
of STDIN,
as this is where it often expects to find form data.  If you have an external program 
sending data
to STDIN, you may be having problems with CGI.pm clobbering the data (to be fair, this 
will happen
with virtually any CGI parsing code).

If an external program is writing to STDIN, can you pipe the data somewhere else and 
read it from
there?

Another tactic:  if you are using CGI.pm but are not using the form-handling code, 
then tell
CGI.pm to take its data from another source.  One way is to do this:

  my $q = CGI->new("");

Then, you can use $q at will without clobbering STDIN.  This is often used for 
debugging when you
want consistent query parameters:

  my $q = CGI->new('color=red&name=Ovid');

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



CGI...blea

2001-06-26 Thread Paul Burkett

Ok, this is odd, I got it so it wont redirect the webpage, but now it won't
change the camera. When I restore it to the original code it changes the
camera but redirects the page to "500 Internet Server Error." Shouldn't
STDIN work in CGI scripts?




RE: Different reply-to?

2001-06-26 Thread Al Hospers

> although I *have*
> gotten into the habit of using "reply-all" instead of
> "reply-to", thus
> getting my mail out to its intended recipient, I receive
> multiple copies of
> the same post from other people who use "reply-all" and don't
> take out
> everybody's name from the To: field.  I have received as many
> as three
> copies of every message in a thread at times.  No wonder I
> download 200+
> messages a day from these two lists alone.
>
> If the list must be set to not mess with the reply-to field,
> could list
> members at least make sure that they cut out addresses from
> the To: field
> before sending their mail?



I think that this topic was chopped off in mid-stream on beginners. in
fact I unsubscribed because when I was active I was getting many
doubled posts a day from that list, on top of the normal traffic. very
annoying! I don't care what emailer you are using, there is no EASY
way to filter out the double postings & it is entirely too easy to do.
IMHO both lists are set up backwards from the myriad other lists I
belong to. most lists have the Reply field to be the reply to the
list, Reply All has the list AND the poster's address. thus you hit
Reply & post back to the list ONLY - which is what most people want to
do and what most posters want you to do. if you really WANT to reply
to the poster directly, something that is often not desired, you click
Reply All & dump the list address.

the way the list is configured now, if you click reply you will NOT
reply to the list at all. thi=us depriving the list members of seeing
the dialog. if you click Reply All, unless you make the effort to
delete the poster's address, they are going to get double postings.

I do not understand the reluctance of the monitors to make this
change.



Al Hospers
CamberSoft, Inc.
alcambersoftcom
http://www.cambersoft.com

A famous linguist once said:
"There is no language wherein a double
positive can form a negative."

YEAH, RIGHT





Re: Script troubles :) plz help

2001-06-26 Thread RDWest Sr.

omg,
   tx yall...   i just did a big boo boo...was rearranging my code and
system froze... no backups... BAHHHlemme get it back together
and i'll post it...
tx again..i'll be a while :((
RD




Re: Script troubles :) plz help

2001-06-26 Thread Brett W. McCoy

On Tue, 26 Jun 2001, RDWest Sr. wrote:

> #!perl
> ##***##
> ##   MAIN  ##
> ##***##
> require "setup.cfg";
> require "html.pl";
>
>
> &parsedata
> if ($INPUT{'signup'}) { &join; }
> else {&html_home; }
> exit;
>
> someone explain what i'm doing wrong plz
> i have my globals in setup.cfg

You aren't using CGI.pm.  I recommend using that for any kind of CGI work
in Perl.  You will wonder who you got along without it when you do.

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

> ok..it all works fineBUT
> i can't use  ( use strict; )
> says it didn't return correct headers or something
> does anyone see a problem in my main code here?

Where are you using strict?  Are you using cgi-lib.pl anywhere?  If you
are, get rid of it!  Use CGI.pm instead.  You will save a lot of
headaches.

-- Brett
   http://www.chapelperilous.net/btfwk/

Don't mind him; politicians always sound like that.




Re: Re: Mainting State On IIS 4 Without Cookies/Hidden Fields

2001-06-26 Thread Mark Bergeron

This may seem like a simple task for those of us whom have some hands on experience 
with Perl but, when I was starting out I couldn't ever get the cookie bit going. There 
are lots of tutorials this is true. None however give simple step by step instruction 
on creating, retrieving and deleting the things. How many of you out there have 
successfully used cookies?

-Original Message-
From: "Curtis Poe"<[EMAIL PROTECTED]>
To: "CGI Beginners"<[EMAIL PROTECTED]>
Date: Tue Jun 26 09:33:53 PDT 2001
Subject: Re: Mainting State On IIS 4 Without Cookies/Hidden Fields

>--- David Simcik <[EMAIL PROTECTED]> wrote:
>> Hi,
>>  I'm looking for a way to maintain session-like state in my perl scripts
>> running on IIS. While I'm certain I've seen modules for this under Apache,
>> are there any equivalents under IIS? I certainly willing to look at
>> workarounds as well. :-)
>> 
>> Thanks.
>> DTS
>
>Since HTTP is a stateless protocol, you're asking a question that has, unfortunately, 
>plagued
>developers for years.  If you're trying to maintain state in httpd sessions, you have 
>a few
>options.
>
>Query strings and extra path information. 
>
>I don't care for this method, as one is forced to try to reliably parse all links in 
>documents.
>
>Cookies.
> 
>This is the most reliable. It's easy to use and doesn't matter if the user leaves 
>your site and
>returns later. However, if your Web site is dedicated to the premise that "BATF 
>employees are
>bunch of jack-booted thugs", many of your users are probably concerned about privacy 
>and have
>cookies disabled.
>
>Hidden fields. 
>
>I like this method, but it only works across a series of form submissions. If the 
>user leaves your
>site and returns later, state information is probably lost.  One can use this with 
>regular Web
>pages if Javascript is enabled and all hyperlinks are turned into form submissions, 
>but this
>requires Javscript to be enabled.
>
>Regardless of the method used, you should probably be employing some form of 
>generating a digest
>or random key for the session id. I prefer the idea of generating a digest with MD5 
>or SHA1, since
>many people who try to generate a random key will do so on their own and not generate 
>a key random
>enough. Unless you're a cryptography wiz (and I'm not), trying to "roll your own" is 
>bad if you
>are really concerned about security. 
>
>Ugh!  I just read your subject.  You want to do this *without* cookies or hidden 
>fields.  You'll
>have to go with the first option, which is ugly.  The problem you're facing is that 
>there is no
>reliable way to ensure that you're talking to the same person at any given time.  
>(IP's can
>frequently change, even for the same person on the same session).
>
>If you're interesting in using user information to generate a digest, the following 
>algorithm is
>listed in 'CGI Programming with Perl', second edition, by O'Reilly (how the heck do 
>you properly
>attribute a book, anyway?  I can never remember): 
>
>use Digest::MD5;
>
>my $md5= new Digest::MD5;
>my $remote = $ENV{REMOTE_ADDR} . $ENV{REMOTE_PORT};
>my $id = $md5->md5_base64( time, $$, $remote );
>$id=~ tr|+/=|-_.|; # Make non-word characters URL-friendly
>
>Further, here's a quote from the book regarding this method: 
>
>This does a good job of generating a unique key for each request. However, it is not 
>intended to
>create keys that cannot be cracked. If you are generating sessions identifiers that 
>provide access
>to sensitive data, then you should use a more sensitive method to generate an 
>identifier.
>
>Cheers,
>Curtis Poe
>
>=
>Senior Programmer
>Onsite! Technology (http://www.onsitetech.com/)
>"Ovid" on http://www.perlmonks.org/
>
>__
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail
>http://personal.mail.yahoo.com/

/~_. _ | _ _  _  _ 
\_/|(_||| | |(_)| |
 _|
___
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com





Re: Script troubles :) plz help

2001-06-26 Thread Casey West

On Tue, Jun 26, 2001 at 02:07:15PM -0400, RDWest Sr. wrote:
: #!perl
: ##***##
: ##   MAIN  ##
: ##***##
: require "setup.cfg";
: require "html.pl";
: 
:   
: &parsedata
: if ($INPUT{'signup'}) { &join; } 
: else {&html_home; }
: exit;
: 
: someone explain what i'm doing wrong plz
: i have my globals in setup.cfg
: i have all my html output in html.pl
: i want the script to add new members to database if signup form is submitted
: else i want the script to print out my homepage
: --
: ok..it all works fineBUT
: i can't use  ( use strict; ) 
: says it didn't return correct headers or something
: does anyone see a problem in my main code here?
: tx

The code that you have given us looks great.  However, you have not
given us the code that you have in your required files.

If you show us the code in your required files, we may be able to tell
you why 'use strict' is failing.

Also, be sure to try and run your program from the command line, you
can see the errors easier.

  Casey West

-- 
"Heavier-than-air flying machines are impossible."
 -- Lord Kelvin, president, Royal Society, 1895.



Script troubles :) plz help

2001-06-26 Thread RDWest Sr.

#!perl
##***##
##   MAIN  ##
##***##
require "setup.cfg";
require "html.pl";

  
&parsedata
if ($INPUT{'signup'}) { &join; } 
else {&html_home; }
exit;

someone explain what i'm doing wrong plz
i have my globals in setup.cfg
i have all my html output in html.pl
i want the script to add new members to database if signup form is submitted
else i want the script to print out my homepage
--
ok..it all works fineBUT
i can't use  ( use strict; ) 
says it didn't return correct headers or something
does anyone see a problem in my main code here?
tx
RD



Re: Mainting State On IIS 4 Without Cookies/Hidden Fields

2001-06-26 Thread fliptop

Curtis Poe wrote:
> 
> listed in 'CGI Programming with Perl', second edition, by O'Reilly (how the heck do 
>you properly
> attribute a book, anyway?  I can never remember):

you can't in an email, because the book title is supposed to be
underlined.

http://www.english.uiuc.edu/cws/wworkshop/bibliography/mla/mlamenu.htm

is a good resource for this type of thing.



Re: Storing hashes & array's on disc

2001-06-26 Thread Brett W. McCoy

On Tue, 26 Jun 2001, Philip Peeters wrote:

> I'm looking for the best way to store an array or hash in a file on disc,
> so it can be picked up by another cgi.

Check out the MLDBM module form CPAN.  It basically ties a hash to a DBM
file, and further allows you to store complex data structures to disk
(which things like DB_File can't do).  You can very easily implement
object persistance with this.

-- Brett
   http://www.chapelperilous.net/btfwk/

Genius, n.:
A chemist who discovers a laundry additive that rhymes with "bright."




Re: Storing hashes & array's on disc

2001-06-26 Thread Timothy Kimball


: I'm looking for the best way to store an array or hash in a file on disc,
: so it can be picked up by another cgi. 
: 
: I'm currently storing to a file where every line contains an element
: (and I know that every 6 lines contain a column in my array). But I find
: this rather...hmmmnot so elegant. 
: 
: Isn't their a sort of "hash dump" that will encapsulate the whole hash
: and dump it in binary on the disc - so that it can be simply read in
: again directly within a hash? 

There are several modules that do things like this:

FreezeThaw   - converts structures to strings; kind of old
Data::Dumper - stores & recovers data structures as ASCII
Storable - stores & recovers data structures or objects
WDDX - stores & recovers parameter sets as XML

Also, if what you want to save is the CGI parameters, CGI.pm has a
save() method that will save the parameters to an open filehandle;
another script can recover them.

-- tdk



Re: Mainting State On IIS 4 Without Cookies/Hidden Fields

2001-06-26 Thread Brett W. McCoy

On Tue, 26 Jun 2001, David Simcik wrote:

>   I'm looking for a way to maintain session-like state in my perl scripts
> running on IIS. While I'm certain I've seen modules for this under Apache,
> are there any equivalents under IIS? I certainly willing to look at
> workarounds as well. :-)

If you are using ASP, there is a global Session object you can access
(although it is nowhere as smart and cool as the Apache::Session stuff).
Otherwise, you will probably need to implement something using DB_File or
similar.

-- Brett
   http://www.chapelperilous.net/btfwk/

Leibowitz's Rule:
When hammering a nail, you will never hit your
finger if you hold the hammer with both hands.




Storing hashes & array's on disc

2001-06-26 Thread Philip Peeters

Hi,

I'm looking for the best way to store an array or hash in a file on disc,
so it can be picked up by another cgi. 

I'm currently storing to a file where every line contains an element
(and I know that every 6 lines contain a column in my array). But I find
this rather...hmmmnot so elegant. 

Isn't their a sort of "hash dump" that will encapsulate the whole hash
and dump it in binary on the disc - so that it can be simply read in
again directly within a hash? 

Philip


___
To get your own FREE ZDNet Onebox - FREE voicemail, email, and fax,
all in one place - sign up today at http://www.zdnetonebox.com




Re: Mainting State On IIS 4 Without Cookies/Hidden Fields

2001-06-26 Thread Curtis Poe

--- David Simcik <[EMAIL PROTECTED]> wrote:
> Hi,
>   I'm looking for a way to maintain session-like state in my perl scripts
> running on IIS. While I'm certain I've seen modules for this under Apache,
> are there any equivalents under IIS? I certainly willing to look at
> workarounds as well. :-)
> 
> Thanks.
> DTS

Since HTTP is a stateless protocol, you're asking a question that has, unfortunately, 
plagued
developers for years.  If you're trying to maintain state in httpd sessions, you have 
a few
options.

Query strings and extra path information. 

I don't care for this method, as one is forced to try to reliably parse all links in 
documents.

Cookies.
 
This is the most reliable. It's easy to use and doesn't matter if the user leaves your 
site and
returns later. However, if your Web site is dedicated to the premise that "BATF 
employees are
bunch of jack-booted thugs", many of your users are probably concerned about privacy 
and have
cookies disabled.

Hidden fields. 

I like this method, but it only works across a series of form submissions. If the user 
leaves your
site and returns later, state information is probably lost.  One can use this with 
regular Web
pages if Javascript is enabled and all hyperlinks are turned into form submissions, 
but this
requires Javscript to be enabled.

Regardless of the method used, you should probably be employing some form of 
generating a digest
or random key for the session id. I prefer the idea of generating a digest with MD5 or 
SHA1, since
many people who try to generate a random key will do so on their own and not generate 
a key random
enough. Unless you're a cryptography wiz (and I'm not), trying to "roll your own" is 
bad if you
are really concerned about security. 

Ugh!  I just read your subject.  You want to do this *without* cookies or hidden 
fields.  You'll
have to go with the first option, which is ugly.  The problem you're facing is that 
there is no
reliable way to ensure that you're talking to the same person at any given time.  
(IP's can
frequently change, even for the same person on the same session).

If you're interesting in using user information to generate a digest, the following 
algorithm is
listed in 'CGI Programming with Perl', second edition, by O'Reilly (how the heck do 
you properly
attribute a book, anyway?  I can never remember): 

use Digest::MD5;

my $md5= new Digest::MD5;
my $remote = $ENV{REMOTE_ADDR} . $ENV{REMOTE_PORT};
my $id = $md5->md5_base64( time, $$, $remote );
$id=~ tr|+/=|-_.|; # Make non-word characters URL-friendly

Further, here's a quote from the book regarding this method: 

This does a good job of generating a unique key for each request. However, it is not 
intended to
create keys that cannot be cracked. If you are generating sessions identifiers that 
provide access
to sensitive data, then you should use a more sensitive method to generate an 
identifier.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re[4]: ? embed scalars in the sql

2001-06-26 Thread Maxim Berlin

Hello mark,

Tuesday, June 26, 2001, mark crowe (JIC) <[EMAIL PROTECTED]> wrote:

mcJ> Not entirely true. Try:
mcJ> $string = "0.0";
mcJ> print $string;
mcJ> - prints "0.0"

mcJ> Now try it without the quotes around 0.0
mcJ> - prints "0"

let's try another approach:

$s = "0.0";
print $s,"\n";
$s+=0.1;
print $s,"\n";

C:\TEMP>perl tt.pl
0.0
0.1

mcJ> So there is a difference between strings and numbers. In the $counter case
mcJ> it doesn't make any difference, but for the above case it could be important
mcJ> - "0.0" is true in a boolean evaluation, while 0 is false, for example. I
mcJ> will admit I have no idea how often it is important though.

mcJ> Incidentally, autoincrement also works for strings anyway, try:
mcJ> $a = "a"; $a++; print $a;
mcJ> so your example would work whether $a is being treated as a string or a
mcJ> number

of course, string can not be numbers :) but numbers always can be
converted into strings.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: Different reply-to?

2001-06-26 Thread Aaron Craig

At 08:51 26.06.2001 -0700, Curtis Poe wrote:
>Okay, maybe I'm just being silly, but I'm a bit tired of hitting "reply" 
>instead of "reply all"
>and forgetting that my message wasn't sent to the list.  While I want to 
>help people who ask
>questions, I'd like this help to be available for all.
>
>I think it would be a Good Thing to change the mailing list so that the 
>"reply to" points back to
>the list instead of the individual who sent the message.  If we still see 
>the original sender's
>email address, direct contact could still be an option.
>
>Any thoughts?

Here we go again :)

I know this thread has been (justly) closed on perl-beginners, and I don't 
want to start another one here, but I do want to say that although I *have* 
gotten into the habit of using "reply-all" instead of "reply-to", thus 
getting my mail out to its intended recipient, I receive multiple copies of 
the same post from other people who use "reply-all" and don't take out 
everybody's name from the To: field.  I have received as many as three 
copies of every message in a thread at times.  No wonder I download 200+ 
messages a day from these two lists alone.

If the list must be set to not mess with the reply-to field, could list 
members at least make sure that they cut out addresses from the To: field 
before sending their mail?


Aaron Craig
Programming
iSoftitler.com




Mainting State On IIS 4 Without Cookies/Hidden Fields

2001-06-26 Thread David Simcik

Hi,
I'm looking for a way to maintain session-like state in my perl scripts
running on IIS. While I'm certain I've seen modules for this under Apache,
are there any equivalents under IIS? I certainly willing to look at
workarounds as well. :-)

Thanks.
DTS




RE: Re[2]: ? embed scalars in the sql

2001-06-26 Thread mark crowe (JIC)

Not entirely true. Try:
$string = "0.0";
print $string;
- prints "0.0"

Now try it without the quotes around 0.0
- prints "0"

So there is a difference between strings and numbers. In the $counter case
it doesn't make any difference, but for the above case it could be important
- "0.0" is true in a boolean evaluation, while 0 is false, for example. I
will admit I have no idea how often it is important though.

Incidentally, autoincrement also works for strings anyway, try:
$a = "a"; $a++; print $a;
so your example would work whether $a is being treated as a string or a
number 

Cheers

Mark C

> 
> Hello mark,
> 
> Tuesday, June 26, 2001, mark crowe (JIC) 
> <[EMAIL PROTECTED]> wrote:
> 
> mcJ> If I might make one other little comment - I suggest you 
> initialise $counter
> mcJ> by $counter=0, rather than $counter="0"; The former 
> makes it a number, the
> mcJ> latter a string.
> (jfyi only)
> you are mistaken. all variables in perl saves as strings; then,
> perl converts string - depends of your needs.
> 
> try:
> 
> $a="0";
> $a++;
> print $a;
> 
> Best wishes,
>  Maximmailto:[EMAIL PROTECTED]
> 
> 



Re: Re: Code Review

2001-06-26 Thread Aaron Craig

At 08:42 26.06.2001 -0700, Curtis Poe wrote:
> >
> > open (IN, "file") || die("Couldn't open file $!");
> > while()
> >  {
> >  chomp;
> >  my @asLines = split(/[\t\s]+/, $_);
> >  Load_Stat_Rec(\@asLines);
> >  }
> > close IN;
>
>I'd be a trifle concerned about this.  First, the character class is 
>unecessary as a tab is
>considered whitespace.  However, I don't know if we have enough of the 
>input data to ensure that
>this will work consistently.  The following record would break this 
>(because of a middle name):
>
>Jones, John Van   35 20 02 05/02/2001 F  060506050705040405047 11 04 01

Good call -- I hadn't thought of that.

Aaron Craig
Programming
iSoftitler.com




Different reply-to?

2001-06-26 Thread Curtis Poe

Okay, maybe I'm just being silly, but I'm a bit tired of hitting "reply" instead of 
"reply all"
and forgetting that my message wasn't sent to the list.  While I want to help people 
who ask
questions, I'd like this help to be available for all.

I think it would be a Good Thing to change the mailing list so that the "reply to" 
points back to
the list instead of the individual who sent the message.  If we still see the original 
sender's
email address, direct contact could still be an option.

Any thoughts?

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Re: Code Review

2001-06-26 Thread Curtis Poe


--- Aaron Craig <[EMAIL PROTECTED]> wrote:
> At 14:44 25.06.2001 -0400, Brian Bukeavich wrote:
> >Thanks for the input.
> >My input data (which is coming out of a flat ascii file) looks similar to:
> >Jones, John   35 20 02 05/02/2001 F  060506050705040405047 11 04 01
> >Jones, John   35 20 02 05/09/2001 F  050604050705040405045 10 13 02
> >Jones, John   35 20 02 05/16/2001 F  050505040704040509048 09 01 03
> >
> >How could I "pass this function an array, or format the string for a 
> >split() or something"?
> 
> open (IN, "file") || die("Couldn't open file $!");
> while()
>  {
>  chomp;
>  my @asLines = split(/[\t\s]+/, $_);
>  Load_Stat_Rec(\@asLines);
>  }
> close IN;

I'd be a trifle concerned about this.  First, the character class is unecessary as a 
tab is
considered whitespace.  However, I don't know if we have enough of the input data to 
ensure that
this will work consistently.  The following record would break this (because of a 
middle name):

Jones, John Van   35 20 02 05/02/2001 F  060506050705040405047 11 04 01

When dealing with fixed width data, I think "unpack" would be a better choice:

my $template = 'a21a3a3a3a11a2a23a3a3a3';

while () {
my @rec = unpack $template, $_;
print join '|', @rec;
print "\n";
}
__DATA__
Jones, John   35 20 02 05/02/2001 F  060506050705040405047 11 04 01
Jones, John   35 20 02 05/09/2001 F  050604050705040405045 10 13 02
Jones, John   35 20 02 05/16/2001 F  050505040704040509048 09 01 03

Of course, the columns may need to be adjusted to suit the individual needs.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re[2]: ? embed scalars in the sql

2001-06-26 Thread Maxim Berlin

Hello mark,

Tuesday, June 26, 2001, mark crowe (JIC) <[EMAIL PROTECTED]> wrote:

mcJ> If I might make one other little comment - I suggest you initialise $counter
mcJ> by $counter=0, rather than $counter="0"; The former makes it a number, the
mcJ> latter a string.
(jfyi only)
you are mistaken. all variables in perl saves as strings; then,
perl converts string - depends of your needs.

try:

$a="0";
$a++;
print $a;

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: Re: Code Review

2001-06-26 Thread Aaron Craig

At 14:44 25.06.2001 -0400, Brian Bukeavich wrote:
>Thanks for the input.
>My input data (which is coming out of a flat ascii file) looks similar to:
>Jones, John   35 20 02 05/02/2001 F  060506050705040405047 11 04 01
>Jones, John   35 20 02 05/09/2001 F  050604050705040405045 10 13 02
>Jones, John   35 20 02 05/16/2001 F  050505040704040509048 09 01 03
>
>How could I "pass this function an array, or format the string for a 
>split() or something"?

open (IN, "file") || die("Couldn't open file $!");
while()
 {
 chomp;
 my @asLines = split(/[\t\s]+/, $_);
 Load_Stat_Rec(\@asLines);
 }
close IN;

and now your function declaration becomes

sub Load_Stat_Rec($)
 {
 my($raLines) = @_;
 # now you don't need to cut up the string, you just access the 
index of the array that you want.
 $name[$i]  = $raLines->[0];
 $course[$i] = $raLines->[1];
 ...
 ...
 }

But I think you need to take a look at how you're storing this 
information.  First of all, your global $i is dangerous and not very 
clear.  If you need to set up a structure that remembers all the data you 
pick up from the file, much better a hash of arrays ie
my %hFileInfo =
 (
 name=> [];
 course  => [];
 tee => [];
 ...
 ...
 );

now you have an hash (associative array) that contains an entry for all of 
your fields.  Each entry is a reference to an array that will pick up all 
of your file input.  So your function becomes:

sub Load_Stat_Rec($)
 {
 my($raLines) = @_;
 # now you don't need to cut up the string, you just access the 
index of the array that you want.
 push(@{ $hFileInfo{name} }, $raLines->[0]);
 push(@{ $hFileInfo{course[} }, $raLines->[1]);
 ...
 ...
 }

which is still WAY too verbose and not very elegant, but at least now 
you've got a structure you can work with easily.
If you have trouble following my syntax, it breaks down like this

%hFileInfo -- this is a hash, or associative array.  That means it is 
composed of name value pairs (name=Joe, age=21, etc.).  If I make a simple hash
my %hHash =
 (
 name => "Frank",
 age =>  21,
 );

I can get the value of an entry (or key) out like so
print $hHah{name}; # prints Frank

Your hash contains arrays at each entry.  So, you want to push() each value 
onto it, building your array as you go.
push(@{ $hFileInfo{name} }, $raLines->[0]);

you have to tell perl to put your hash value 'name' into list (or array) 
context to use the function push() on it, as push only works with an array, 
and you do that as in the example above, putting it inside @{} (some people 
prefer @$hFileInfo{name}, but I think the curly brackets make it more 
obvious that you meant to do that and that it isn't a typo, and makes it 
easier to read)

>Another thing I would really like to clean up is the redundancy in output...
>is there a way I can write to both:
> printf OF (" %3u", @hole[$q]);
> printf OF2 (" %3u", @hole[$q]);

Perhaps you're writing to two files needlessly?  Or, if you need two 
copies, can't you write to one and then copy it to another file at the 
end?  Why are you writing the same thing to two files?

Aaron Craig
Programming
iSoftitler.com




RE: ? embed scalars in the sql

2001-06-26 Thread Curtis Poe

--- Francesco Scaglioni <[EMAIL PROTECTED]> wrote:
> Thanks and Hi again,
> 
> Tried unescaping and got no joy so tried the following - still with no
> joy -any suggestions as to which obvious thing I am missing.
> 
> #!/usr/bin/perl -w
> #
> # test script to query an mysql database
> #
> use strict;
> use DBI;

Francesco,

I'm afraid I don't have any answers, but I have some debugging suggestions.

After the use DBI statement, try adding this:

DBI->trace( 2, "dbi_debug.log" );

When this method is called on DBI, it will start a "trace" of you interactions with 
the DBI and
the trace will be saved to the filename you specify.  If all else fails, this can be 
*incredibly*
useful.  You may wish to consider upping the trace level (the number 2) to output more
information.

>From the documentation:

`trace'
  DBI->trace($trace_level)
  DBI->trace($trace_level, $trace_filename)

DBI trace information can be enabled for all handles using the
`trace' DBI class method. To enable trace information for a specific
handle, use the similar `$h-'>`trace' method described elsewhere.

Trace levels are as follows:

  0 - Trace disabled.
  1 - Trace DBI method calls returning with results or errors.
  2 - Trace method entry with parameters and returning with results.
  3 - As above, adding some high-level information from the driver
  and some internal information from the DBI.
  4 - As above, adding more detailed information from the driver.
  Also includes DBI mutex information when using threaded Perl.
  5 and above - As above but with more and more obscure information.

Trace level 1 is best for a simple overview of what's happening.
Trace level 2 is a good choice for general purpose tracing. Levels 3
and above (up to 9) are best reserved for investigating a specific
problem, when you need to see "inside" the driver and DBI.

The trace output is detailed and typically very useful. Much of the
trace output is formatted using the the neat entry elsewhere in this
document function, so strings in the trace output may be edited and
truncated.

Initially trace output is written to `STDERR'. If `$trace_filename'
is specified, then the file is opened in append mode and all trace
output (including that from other handles) is redirected to that
file. Further calls to `trace' without a `$trace_filename' do not
alter where the trace output is sent. If `$trace_filename' is
undefined, then trace output is sent to `STDERR' and the previous
trace file is closed.

See also the $h->trace and $h->trace_msg methods and the the
DEBUGGING entry elsewhere in this document section for information
about the `DBI_TRACE' environment variable.

I'd also set the "RaiseError" property.  When you do that, errors will be raised 
automatically
with each call to the DBI object and you won't have to check for them individually.  
Here's how I
would instantiate the object:

$dbh = DBI->connect( "DBI:mysql:ami","fgs",{ RaiseError => 1 } )
   or die DBI->errstr;

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Re: Unsubscribing

2001-06-26 Thread Mark Bergeron

You boys are all going to have to figure this one out.
Consider it a learning experience.

-Original Message-
From: "Lucy"<[EMAIL PROTECTED]>
To: "Cochrane, Paul"<[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Date: Tue Jun 26 03:58:03 PDT 2001
Subject: Re: Unsubscribing

>I have no idea why everyone is finding it so hard to unsubscribe. :)
>I have tried it once again, and had no problems.
>
>1) send email to
>
> [EMAIL PROTECTED]
>
>(yes, substituting "username-somewhere.com" from your real address) 
>
>=)
>
>2) you will receive an email with the subject "confirm unsubscribe from 
>[EMAIL PROTECTED]"
>
>3) send a blank email to the *address specified* in the email. 
>The relevant part of the email should look something like this:-
>
>
>To confirm that you would like
>
>   [EMAIL PROTECTED]
>
>removed from the beginners-cgi mailing list, please send an empty reply
>to this address:
>
>[EMAIL PROTECTED]
>
>
>
>It should also be the address in the "Reply-to" header,  make sure your mail client 
>uses this
>"reply-to" header or alternately paste the email adress into your mail client.
>There is a clickable "mailto" link if your client utilises html links too.
>
>Send a blank email to this address.
>
>4) Receive the email entitled "GOODBYE from [EMAIL PROTECTED]" and you are 
>unsubscribed.
>
>Can anyone still having problems please point out at which stage the unsubscribe 
>process is going wrong for you? 
>
>We'll try and get it sorted once and for all. ;-)
>With more detail of where the problem is, perhaps we can change the info on 
>learn.perl.org 
>or make the instructions in the "WELCOME to [EMAIL PROTECTED]" email clearer.
>
>
>
>--lucy
>
>
>
>> Me too. Please will someone remove me from this list?
>> 
>> -Original Message-
>> From: Derek Harding [mailto:[EMAIL PROTECTED]]
>> Sent: 26 June 2001 10:26
>> To: [EMAIL PROTECTED]
>> Subject: Unsubscribing
>> 
>> 
>> In company with Bernhard and others I am having immense problems getting 
>> myself unsubscribed.
>> 
>> On one hand I get automated mail telling me to reply, which I duly do, then 
>> it tells me I'm not subscribed but clearly, I am!
>> 
>> Dare I suggest that this part of the service is broken?
>> 
>> PLEASE take me off the list!!!
>> 
>> -- 
>> Best wishes,
>> Derek Harding, (BA MIAP)
>> ICT & Network Manager
>> [EMAIL PROTECTED]
>
>
>-- 
>  .-"""-. 
> /* * * *\
>:_.-:`:-._;  [EMAIL PROTECTED]
>(_)  http://triffid.org
>_\|/(_)\|/
>

/~_. _ | _ _  _  _ 
\_/|(_||| | |(_)| |
 _|
___
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com





RE: why perl - idc - htx - won't work in PWS

2001-06-26 Thread Kris Cook

Ah, PWS (Pretty Weak Stuff?).  I've been in the same boat.  There are
several odd things that have happened, and every time it turned out to be
that PWS was whacked out.  The solution in all cases:
1. Remove PWS.
2. Reboot.
3. Re-install PWS.

Suddenly, voila, it works.  In my case, it apparently keeps wigging out
because when I take my laptop home, I always cancel out of the network login
so as to avoid waiting for my network shares, etc., which can take an
additional 5 minutes.  Well, every time I do that, PWS tries to start as
it's been instructed, can't find the network, and a little piece of it dies,
apparently from rejection or neglect.  I remove and re-install, and it's
fine.

> -Original Message-
> From: Frederick Alain Ang Yap [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 26, 2001 5:52 AM
> To: [EMAIL PROTECTED]
> Subject: why perl - idc - htx - won't work in PWS
> 
> 
> does anyone here have ever tried using perl - idc - htx (MS Access)
> connection on a Windows via Personal Web Server?  I don't 
> know why I can't
> get it done.  I already installed the Active Perl kit, but it 
> still won't do
> any good.
> 
> 
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 



RE: ? embed scalars in the sql

2001-06-26 Thread mark crowe (JIC)

Yes, I agree with Christian about the fieldnames being quoted - I'd just
worked out the same thing here. Sorry, I though placeholders would work for
field names, obviously not. 

If I might make one other little comment - I suggest you initialise $counter
by $counter=0, rather than $counter="0"; The former makes it a number, the
latter a string. It will probably work either way, but it's generally better
to define numerical variables without quotes.

Cheers

Mark C

> -Original Message-
> From: Sage, Christian [mailto:[EMAIL PROTECTED]]
> Sent: 26 June 2001 13:17
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: AW: ? embed scalars in the sql
> 
> 
> Francesco,
> 
> here is an amended and simplified version of your script that 
> worked on my computer 30secs ago:
> 
> ---< snip
> 
> #!/usr/bin/perl -w
> #
> # test script to query an mysql database
> #
> use strict;
> use DBI;
> 
> my ($sql, $dbh, $sth, $field1, $value1, $field2, $value2, 
> @rows, $counter);
> 
> print "Enter the first fieldname (field1)   : "; chomp 
> ($field1 = <>);
> print "enter the value for field one (value1)   : "; chomp 
> ($value1 = <>);
> print "Enter the second fieldname (field2)  : "; chomp 
> ($field2 = <>);
> print "enter the value for field two (value2)   : "; chomp 
> ($value2 = <>);
> 
> $dbh = DBI -> connect ("DBI:Oracle:SID", "sys", 
> "***") || die $DBI::errstr;
> $sql = "SELECT * FROM sapr3.t000 WHERE $field1 = '$value1' 
> and $field2 = '$value2'";
> $sth = $dbh -> prepare($sql);
> $sth -> execute();
> $counter = "0";
> while ( @rows = $sth  -> fetchrow_array())  {
> $counter++;
> print "@rows\n";
> }
> print "Number of records  =  $counter\n\n";
> $dbh -> disconnect;
> 
> ---< snip
> 
> I've tried to change as little possible, but for (obvious) 
> security reasons I've changed the database name and password. 
> The query returned exactly one row. I guess in your version 
> the problem is that the substitution values for the field 
> names end up being quoted, which gives you a condition that 
> is always false. I've not verified that, though (and may get 
> beaten over the head for suggesting it ;-). Hope this helps.
> 
> Cheers,
> Christian Sage
> 
> -Ursprüngliche Nachricht-
> Von: Francesco Scaglioni [mailto:[EMAIL PROTECTED]]
> Gesendet am: Dienstag, 26. Juni 2001 13:43
> An: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Betreff: RE: ? embed scalars in the sql
> 
> The following still reports nil records (I know they are there -
> honest!!).
> 



AW: ? embed scalars in the sql

2001-06-26 Thread Sage, Christian

Francesco,

here is an amended and simplified version of your script that worked on my computer 
30secs ago:

---< snip

#!/usr/bin/perl -w
#
# test script to query an mysql database
#
use strict;
use DBI;

my ($sql, $dbh, $sth, $field1, $value1, $field2, $value2, @rows, $counter);

print "Enter the first fieldname (field1)   : "; chomp ($field1 = <>);
print "enter the value for field one (value1)   : "; chomp ($value1 = <>);
print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
print "enter the value for field two (value2)   : "; chomp ($value2 = <>);

$dbh = DBI -> connect ("DBI:Oracle:SID", "sys", "***") || die $DBI::errstr;
$sql = "SELECT * FROM sapr3.t000 WHERE $field1 = '$value1' and $field2 = '$value2'";
$sth = $dbh -> prepare($sql);
$sth -> execute();
$counter = "0";
while ( @rows = $sth  -> fetchrow_array())  {
$counter++;
print "@rows\n";
}
print "Number of records  =  $counter\n\n";
$dbh -> disconnect;

---< snip

I've tried to change as little possible, but for (obvious) security reasons I've 
changed the database name and password. The query returned exactly one row. I guess in 
your version the problem is that the substitution values for the field names end up 
being quoted, which gives you a condition that is always false. I've not verified 
that, though (and may get beaten over the head for suggesting it ;-). Hope this helps.

Cheers,
Christian Sage

-Ursprüngliche Nachricht-
Von: Francesco Scaglioni [mailto:[EMAIL PROTECTED]]
Gesendet am: Dienstag, 26. Juni 2001 13:43
An: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Betreff: RE: ? embed scalars in the sql

The following still reports nil records (I know they are there -
honest!!).

TIA - Francesco

#!/usr/bin/perl -w
#
# test script to query an mysql database
#
use strict;
use DBI;

my ($sql, $dbh, $sth, $field1, $value1, $field2, $value2, @rows, $counter);

print "Enter the first fieldname (field1)   : "; chomp ($field1 = <>);
print "enter the value for field one (value1)   : "; chomp ($value1 = <>);
print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
print "enter the value for field two (value2)   : "; chomp ($value2 = <>);

$dbh = DBI -> connect ("DBI:mysql:ami","fgs") || die $DBI::errstr;
$sql = qq{SELECT * FROM testami WHERE ? = ? and ? = ?};
$sth = $dbh -> prepare($sql);
$sth -> execute($field1, $value1, $field2, $value2);
$sth -> execute();
$counter = "0";
while ( @rows = $sth  -> fetchrow_array())  {
$counter++;
print "@rows\n";
}
print "Number of records  =  $counter\n\n";
$dbh -> disconnect;



Re: HTTP headers/Mime types

2001-06-26 Thread Hasanuddin Tamir

On Tue, 26 Jun 2001, Gary Stainburn <[EMAIL PROTECTED]> wrote,

> Hi all,
>
> I've written a perl script that creates PDF files containing our sales
> invoices and it works fine writing the PDF's to disk. (Actually it creates a
> postscript file and runs ps2pdf).
>
> I now want to embed this inside a CGI so people can view them on-line and
> have their browser fire off acroread.
>
> To do this I need to set the correct MIME type in the http header.  Is there
> a list of the correct MIME types to use.  I will soon be wanting to do a
> similar thing with CSV and excel files amongst others.

Yes, right in your box, /etc/mime.types.  Windows has it somewhere
in registry.


__END__
-- 
s::a::n->http(www.trabas.com)




RE: ? embed scalars in the sql

2001-06-26 Thread Francesco Scaglioni

The following still reports nil records (I know they are there -
honest!!).

TIA - Francesco

#!/usr/bin/perl -w
#
# test script to query an mysql database
#
use strict;
use DBI;

my ($sql, $dbh, $sth, $field1, $value1, $field2, $value2, @rows, $counter);

print "Enter the first fieldname (field1)   : "; chomp ($field1 = <>);
print "enter the value for field one (value1)   : "; chomp ($value1 = <>);
print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
print "enter the value for field two (value2)   : "; chomp ($value2 = <>);

$dbh = DBI -> connect ("DBI:mysql:ami","fgs") || die $DBI::errstr;
$sql = qq{SELECT * FROM testami WHERE ? = ? and ? = ?};
$sth = $dbh -> prepare($sql);
$sth -> execute($field1, $value1, $field2, $value2);
$sth -> execute();
$counter = "0";
while ( @rows = $sth  -> fetchrow_array())  {
$counter++;
print "@rows\n";
}
print "Number of records  =  $counter\n\n";
$dbh -> disconnect;



HTTP headers/Mime types

2001-06-26 Thread Gary Stainburn

Hi all,

I've written a perl script that creates PDF files containing our sales 
invoices and it works fine writing the PDF's to disk. (Actually it creates a 
postscript file and runs ps2pdf).

I now want to embed this inside a CGI so people can view them on-line and 
have their browser fire off acroread.

To do this I need to set the correct MIME type in the http header.  Is there 
a list of the correct MIME types to use.  I will soon be wanting to do a 
similar thing with CSV and excel files amongst others.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 



Re: Unsubscribing

2001-06-26 Thread Lucy

I have no idea why everyone is finding it so hard to unsubscribe. :)
I have tried it once again, and had no problems.

1) send email to

 [EMAIL PROTECTED]

(yes, substituting "username-somewhere.com" from your real address) 

=)

2) you will receive an email with the subject "confirm unsubscribe from 
[EMAIL PROTECTED]"

3) send a blank email to the *address specified* in the email. 
The relevant part of the email should look something like this:-


To confirm that you would like

   [EMAIL PROTECTED]

removed from the beginners-cgi mailing list, please send an empty reply
to this address:

[EMAIL PROTECTED]



It should also be the address in the "Reply-to" header,  make sure your mail client 
uses this
"reply-to" header or alternately paste the email adress into your mail client.
There is a clickable "mailto" link if your client utilises html links too.

Send a blank email to this address.

4) Receive the email entitled "GOODBYE from [EMAIL PROTECTED]" and you are 
unsubscribed.

Can anyone still having problems please point out at which stage the unsubscribe 
process is going wrong for you? 

We'll try and get it sorted once and for all. ;-)
With more detail of where the problem is, perhaps we can change the info on 
learn.perl.org 
or make the instructions in the "WELCOME to [EMAIL PROTECTED]" email clearer.



--lucy



> Me too. Please will someone remove me from this list?
> 
> -Original Message-
> From: Derek Harding [mailto:[EMAIL PROTECTED]]
> Sent: 26 June 2001 10:26
> To: [EMAIL PROTECTED]
> Subject: Unsubscribing
> 
> 
> In company with Bernhard and others I am having immense problems getting 
> myself unsubscribed.
> 
> On one hand I get automated mail telling me to reply, which I duly do, then 
> it tells me I'm not subscribed but clearly, I am!
> 
> Dare I suggest that this part of the service is broken?
> 
> PLEASE take me off the list!!!
> 
> -- 
> Best wishes,
> Derek Harding, (BA MIAP)
> ICT & Network Manager
> [EMAIL PROTECTED]


-- 
  .-"""-. 
 /* * * *\
:_.-:`:-._;  [EMAIL PROTECTED]
(_)  http://triffid.org
_\|/(_)\|/




RE: ? embed scalars in the sql

2001-06-26 Thread PURMONEN, Joni

Take the safe option and assign the SQL query to a string before using it.
The placeholders are ok with this as well.

my $sql = qq(select *  from testami where ? = ? and ? = ?);

$sth = $dbh -> prepare($sql);
$sth -> execute($field1, $value1, $field2, $value2);

#$sth -> execute();

Hope you didn't forget to uncomment this one!

Joni



RE: ? embed scalars in the sql

2001-06-26 Thread Francesco Scaglioni

Thanks and Hi again,

Tried unescaping and got no joy so tried the following - still with no
joy -any suggestions as to which obvious thing I am missing.

#!/usr/bin/perl -w
#
# test script to query an mysql database
#
use strict;
use DBI;

my ( $dbh, $value1, $value2, $sth, @rows, $counter, $field_name, $field2, $field1);

print "Enter the first fieldname (field1)  : "; chomp ($field1 = <>);
print "enter the value for field one   : "; chomp ($value1 = <>);
print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
print "enter the value for field two   : "; chomp ($value2 = <>);

$dbh = DBI -> connect ("DBI:mysql:ami","fgs") || die $DBI::errstr;

$sth = $dbh -> prepare( qq{select *  from testami where ? = ? and ? = ?});
$sth -> execute($field1, $value1, $field2, $value2);

#$sth -> execute();
$counter = "0";
while ( @rows = $sth  -> fetchrow_array())  {
$counter++;
print "@rows\n";
}
print "Number of records  =  $counter\n\n";
$dbh -> disconnect;

Thanks

Francesco



why perl - idc - htx - won't work in PWS

2001-06-26 Thread Frederick Alain Ang Yap

does anyone here have ever tried using perl - idc - htx (MS Access)
connection on a Windows via Personal Web Server?  I don't know why I can't
get it done.  I already installed the Active Perl kit, but it still won't do
any good.


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




RE: ? embed scalars in the sql

2001-06-26 Thread mark crowe (JIC)

Hi Francesco

I would guess that the problem is caused by you escaping the $ signs in your
SELECT statement (eg \$fields). Try using something like:-
$sth = $dbh -> prepare(qq{select *  from testami where '$field1'  = 
'$value1' and '$field2' = '$value2'});

or at least remove the \ before the $variables. If you use \$field1 you are
passing the literal string '$field1' to your search, rather than the
interpolated value of $field1.

You might want to start looking into placeholders too. In this case you
would use:
$sth = $dbh -> prepare( qq{select *  from testami where ? = ? and ? =
?});
$sth -> execute($field1, $value1, $field2, $value2);

The ?'s are replaced (in order) by the values in the brackets after the
execute; again these will be interpolated.

Cheers

Mark C

P.S. Don't apologise for posting the script. It makes things much easier to
fix if we can see the problem. 8-)

> -Original Message-
> From: Francesco Scaglioni [mailto:[EMAIL PROTECTED]]
> Sent: 26 June 2001 10:10
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: ? embed scalars in the sql
> 
> 
> Apologies for posting a small script.  I created a little test table
> with columns testname, testsex, testage and testcolour.  The script
> runs without errors yet the value of returned rows is always zero.
> Please would someone be so kind as to point out the error of my ways.
> 
> TIA
> 
> Francesco
> 
> #!/usr/bin/perl -w
> #
> # test script to query an mysql database
> #
> use strict;
> use DBI;
> 
> my ( $dbh, $value1, $value2, $sth, @rows, $counter, 
> $field_name, $field2, $field1);
> 
> print "Enter the first fieldname (field1)  : "; chomp ($field1 = <>);
> print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
> print "enter the value for field one   : "; chomp ($value1 = <>);
> print "enter the value for field two   : "; chomp ($value2 = <>);
> 
> $dbh = DBI -> connect ("DBI:mysql:ami","fgs") || die $DBI::errstr;
> $sth = $dbh -> prepare( qq{
>select *  from testami where \"\$field1\"  = 
> \"$value1\" and \"\$field2\" = \"\$value2\"
> });
> 
> $sth -> execute();
>  $counter = "0";
> while ( @rows = $sth  -> fetchrow_array ())  {
> $counter++;
> print "@rows\n";
> }
> print "Number of records  =  $counter\n\n";
> $dbh -> disconnect;
> 



RE: Unsubscribing

2001-06-26 Thread Cochrane, Paul

Me too. Please will someone remove me from this list?

-Original Message-
From: Derek Harding [mailto:[EMAIL PROTECTED]]
Sent: 26 June 2001 10:26
To: [EMAIL PROTECTED]
Subject: Unsubscribing


In company with Bernhard and others I am having immense problems getting 
myself unsubscribed.

On one hand I get automated mail telling me to reply, which I duly do, then 
it tells me I'm not subscribed but clearly, I am!

Dare I suggest that this part of the service is broken?

PLEASE take me off the list!!!

-- 
Best wishes,
Derek Harding, (BA MIAP)
ICT & Network Manager
[EMAIL PROTECTED]



Unsubscribing

2001-06-26 Thread Derek Harding

In company with Bernhard and others I am having immense problems getting 
myself unsubscribed.

On one hand I get automated mail telling me to reply, which I duly do, then 
it tells me I'm not subscribed but clearly, I am!

Dare I suggest that this part of the service is broken?

PLEASE take me off the list!!!

-- 
Best wishes,
Derek Harding, (BA MIAP)
ICT & Network Manager
[EMAIL PROTECTED]



AW: ? embed scalars in the sql

2001-06-26 Thread Sage, Christian

"Until you execute it" is only true if you omit the prepare step. If you do a prepare 
first all scalars are resolved at that point in time. After the prepare you can only 
bind values to substitution parameters (if any), either through using one of the 
bind_param functions or directly in the execute call.

I admit I'm counting beans here, but sometimes beans can be fairly important in 
programming ...

Cheers,
Christian Sage

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Gesendet am: Montag, 25. Juni 2001 21:42
An: [EMAIL PROTECTED]
Betreff: Re: ? embed scalars in the sql


: Is it possible to embed a scalar into the sql such that the value of
: the scalar could represent a column name to report or a value to
: select by

Sure. The query's just a scalar string until you execute it.

Same goes for order by, group by, table names, or whatever. Just do
yourself a favor and trap the errors that come back from the database
interface (DBI, hopefully).

-- tdk



Re: ? embed scalars in the sql

2001-06-26 Thread Francesco Scaglioni

Apologies for posting a small script.  I created a little test table
with columns testname, testsex, testage and testcolour.  The script
runs without errors yet the value of returned rows is always zero.
Please would someone be so kind as to point out the error of my ways.

TIA

Francesco

#!/usr/bin/perl -w
#
# test script to query an mysql database
#
use strict;
use DBI;

my ( $dbh, $value1, $value2, $sth, @rows, $counter, $field_name, $field2, $field1);

print "Enter the first fieldname (field1)  : "; chomp ($field1 = <>);
print "Enter the second fieldname (field2)  : "; chomp ($field2 = <>);
print "enter the value for field one   : "; chomp ($value1 = <>);
print "enter the value for field two   : "; chomp ($value2 = <>);

$dbh = DBI -> connect ("DBI:mysql:ami","fgs") || die $DBI::errstr;
$sth = $dbh -> prepare( qq{
   select *  from testami where \"\$field1\"  = \"$value1\" and \"\$field2\" = 
\"\$value2\"
});

$sth -> execute();
 $counter = "0";
while ( @rows = $sth  -> fetchrow_array ())  {
$counter++;
print "@rows\n";
}
print "Number of records  =  $counter\n\n";
$dbh -> disconnect;



Re: If I could get just one Perl Book what should it be?

2001-06-26 Thread Chris Hedemark

You'll probably get a few of these, but the Llama book from O'Reilly &
Associates "Learning Perl" is the way to go.

Chris Hedemark - Hillsborough, NC
http://yonderway.com
- Original Message -
From: "Brian Jackson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 25, 2001 10:03 AM
Subject: If I could get just one Perl Book what should it be?


> To all,
>
> I have programmed in C, Fortran, C++, Java, Awk, Korn Shell, but  I am
> new to Perl.   I already have a few quick reference documentation for
> Perl in a Linux in a nutshell book.   I have money to buy just one Perl
> book.   What is the best one book that I can get to teach me Perl??
>
> Thanks in advance.
> Brian
>