[29925] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1170 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 3 21:53:44 2008

Date: Thu, 3 Jan 2008 15:09:08 -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           Thu, 3 Jan 2008     Volume: 11 Number: 1170

Today's topics:
    Re: anyone have a working captcha perl script for windo <lihao0129@gmail.com>
    Re: anyone have a working captcha perl script for windo <jack_posemsky@yahoo.com>
    Re: anyone have a working captcha perl script for windo <jack_posemsky@yahoo.com>
    Re: calling perl from html page <motic.mail@gmail.com>
    Re: calling perl from html page <joost@zeekat.nl>
    Re: calling perl from html page <purlgurl@purlgurl.net>
    Re: calling perl from html page <purlgurl@purlgurl.net>
    Re: calling perl from html page <motic.mail@gmail.com>
    Re: calling perl from html page <purlgurl@purlgurl.net>
    Re: calling perl from html page <purlgurl@purlgurl.net>
    Re: calling perl from html page <motic.mail@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 3 Jan 2008 11:38:09 -0800 (PST)
From: "lihao0129@gmail.com" <lihao0129@gmail.com>
Subject: Re: anyone have a working captcha perl script for windows ?
Message-Id: <f8fb1ce7-d419-4aa2-b897-fb98eb28641a@d4g2000prg.googlegroups.com>

On Jan 3, 10:53=C2=A0am, Jack <jack_posem...@yahoo.com> wrote:
> On Jan 2, 10:42=C2=A0pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote=
:
>
>
>
>
>
> > On Jan 3, 1:12 am, Jack <jack_posem...@yahoo.com> wrote:
>
> > > Hi there, I have installed every CPAN Captcha image verification known=

> > > and cant get any of them to do a simple task - output to a directory a=

> > > set of Captcha images with codes and the code file..you would think
> > > its simple, I tried GD:SecurityImage and this does nothing:
>
> > > =C2=A0use GD::SecurityImage;
>
> > > =C2=A0 =C2=A0# Create a normal image
> > > =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D> 80=
,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =C2=A0=
=3D> 30,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=A0 =
=3D> 10,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =3D> =
'giant');
> > > =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> > > =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> > > =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $image->o=
ut;
>
> > > It runs but you have no way of knowing "where" the images were
> > > placed. =C2=A0can anyone reply with a true to life working SIMPLE scri=
pt
> > > that just dumps the images and code file ??????
>
> > I suppose you were in a web-context, so you need to print out the
> > result to STDOUT. you need also send out content-type header before
> > sending your image data.. what I did with HTML::Mason:
>
> > =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->out;
> > =C2=A0 =C2=A0 binmode STDOUT;
> > =C2=A0 =C2=A0 $m->clear_buffer();
> > =C2=A0 =C2=A0 $r->content_type("image/$mime_type") ;
> > =C2=A0 =C2=A0 $m->print($image_data);
> > =C2=A0 =C2=A0 $m->flush_buffer();
> > =C2=A0 =C2=A0 $m->abort();
>
> > If you were using plain-CGI, and your script filename is captcha.cgi,
> > then you probably can do things like:[sorry I have no experience with
> > plain CGI]
>
> > =C2=A0 =C2=A0 {
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 local $|++;
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->out;=

> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 binmode STDOUT;
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print "Content-type=3Dimage/$mime_type";
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print $image_data;
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 close STDOUT;
> > =C2=A0 =C2=A0 }
>
> > or something like that to print out image data to the web with a
> > proper content-type(make sure no other data are outputted before
> > sending content-type header), and then you can fetch it from the other
> > side with:
> > =C2=A0 =C2=A0 <img src=3D"/path/to/captcha.cgi?R=3D..." alt=3D"" />
>
> > For me, the random number is generated from outside captcha.cgi, and
> > passed in with an encrypted query string(i.e. R=3D#### as in the above
> > sample). you can then decrypt it at the beginning of your Perl script
> > captcha.cgi.. If you like this approach, you need also check out CPAN
> > for some Crypt:: modules(I am using Crypt::RC4 for this).
>
> > BTW. with GD::ImageSecurity, you dont need any temporary file to save
> > the images....
>
> > Good luck,
> > lihao- Hide quoted text -
>
> > - Show quoted text -
>
> Hey thanks but that doesnt help - looking for a simple script that
> dumps to a DIRECTORY on WINDOWS captcha images and their code file.
>
> Your code produces errors when I integrate it:
>
> =C2=A0 =C2=A0use GD::SecurityImage;
> use HTML::Mason;
>
> =C2=A0 =C2=A0# Create a normal image
> =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D> 80,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =C2=A0=3D=
> 30,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=A0 =3D=
> 10,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =3D> 'gi=
ant');
> $your_random_str =3D '2345';
> =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $image->out;
>
> =C2=A0print " 1 =C2=A0$image_data =C2=A0 2 =C2=A0 $mime_type =C2=A03 =C2=
=A0$random_number 4 $image
> ";
>
> =C2=A0 =C2=A0 binmode STDOUT;
> =C2=A0 =C2=A0 $m->clear_buffer();
> =C2=A0 =C2=A0 $r->content_type("$image/$mime_type") ;
> =C2=A0 =C2=A0 $m->print($image_data);
> =C2=A0 =C2=A0 $m->flush_buffer();
> =C2=A0 =C2=A0 $m->abort();

I am not sure how you configured HTML::Mason with your site, but
before you use $m and $r objects under CGI, you should at least
instantiate them, otherwise they invoke ERRORs for undefined
variables... the point is sending out the correct content-type header,
and clearing non-related buffers before and after your image data, and
printing to STDOUT with binmode to generate the image on the fly.. no
need for a temporary file, this at least works under Linux box...

lihao

> ##### I Tried adding this but it doesnt help:
> $filename1 =3D 'c:\tmp\test.png';
> open(OUTFILE,">$filename1")|| die 'ERROR : external table not found :'.
> $filename1."\n";
> print OUTFILE $image_data;
> # =C2=A0print OUTFILE out;
>
> ########
> Results Errors:
> 1 =C2=A05=E2=88=9E=CF=83=C3=B7w?=E2=8C=82=C2=AB=E2=89=A4 =C2=A0 =C2=A0 =C2=
=A0 =E2=89=88=E2=95=91=C2=B1L=C3=B2=E2=98=BA- =C2=A0 =C2=A0IEND=C2=ABB`=C3=
=A9 =C2=A0 2 =C2=A0 png =C2=A03 =C2=A0671027 4
> GD::SecurityImage=3DHAS
> H(0x18300bc) Can't call method "content_type" on an undefined value at
> cap.pl li
> ne 21. =C2=A0(same with clear_buffer and flush_buffer- Hide quoted text -
>
> - Show quoted text -



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

Date: Thu, 3 Jan 2008 12:54:20 -0800 (PST)
From: Jack <jack_posemsky@yahoo.com>
Subject: Re: anyone have a working captcha perl script for windows ?
Message-Id: <38dda04c-01e6-4ba3-9b93-155e1674531a@i29g2000prf.googlegroups.com>

On Jan 3, 11:38=C2=A0am, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
> On Jan 3, 10:53=C2=A0am, Jack <jack_posem...@yahoo.com> wrote:
>
>
>
>
>
> > On Jan 2, 10:42=C2=A0pm, "lihao0...@gmail.com" <lihao0...@gmail.com> wro=
te:
>
> > > On Jan 3, 1:12 am, Jack <jack_posem...@yahoo.com> wrote:
>
> > > > Hi there, I have installed every CPAN Captcha image verification kno=
wn
> > > > and cant get any of them to do a simple task - output to a directory=
 a
> > > > set of Captcha images with codes and the code file..you would think
> > > > its simple, I tried GD:SecurityImage and this does nothing:
>
> > > > =C2=A0use GD::SecurityImage;
>
> > > > =C2=A0 =C2=A0# Create a normal image
> > > > =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D> =
80,
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =
=C2=A0=3D> 30,
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=
=A0 =3D> 10,
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =
=3D> 'giant');
> > > > =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> > > > =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> > > > =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $image-=
>out;
>
> > > > It runs but you have no way of knowing "where" the images were
> > > > placed. =C2=A0can anyone reply with a true to life working SIMPLE sc=
ript
> > > > that just dumps the images and code file ??????
>
> > > I suppose you were in a web-context, so you need to print out the
> > > result to STDOUT. you need also send out content-type header before
> > > sending your image data.. what I did with HTML::Mason:
>
> > > =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->out;
> > > =C2=A0 =C2=A0 binmode STDOUT;
> > > =C2=A0 =C2=A0 $m->clear_buffer();
> > > =C2=A0 =C2=A0 $r->content_type("image/$mime_type") ;
> > > =C2=A0 =C2=A0 $m->print($image_data);
> > > =C2=A0 =C2=A0 $m->flush_buffer();
> > > =C2=A0 =C2=A0 $m->abort();
>
> > > If you were using plain-CGI, and your script filename is captcha.cgi,
> > > then you probably can do things like:[sorry I have no experience with
> > > plain CGI]
>
> > > =C2=A0 =C2=A0 {
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 local $|++;
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->ou=
t;
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 binmode STDOUT;
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print "Content-type=3Dimage/$mime_type";
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print $image_data;
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 close STDOUT;
> > > =C2=A0 =C2=A0 }
>
> > > or something like that to print out image data to the web with a
> > > proper content-type(make sure no other data are outputted before
> > > sending content-type header), and then you can fetch it from the other=

> > > side with:
> > > =C2=A0 =C2=A0 <img src=3D"/path/to/captcha.cgi?R=3D..." alt=3D"" />
>
> > > For me, the random number is generated from outside captcha.cgi, and
> > > passed in with an encrypted query string(i.e. R=3D#### as in the above=

> > > sample). you can then decrypt it at the beginning of your Perl script
> > > captcha.cgi.. If you like this approach, you need also check out CPAN
> > > for some Crypt:: modules(I am using Crypt::RC4 for this).
>
> > > BTW. with GD::ImageSecurity, you dont need any temporary file to save
> > > the images....
>
> > > Good luck,
> > > lihao- Hide quoted text -
>
> > > - Show quoted text -
>
> > Hey thanks but that doesnt help - looking for a simple script that
> > dumps to a DIRECTORY on WINDOWS captcha images and their code file.
>
> > Your code produces errors when I integrate it:
>
> > =C2=A0 =C2=A0use GD::SecurityImage;
> > use HTML::Mason;
>
> > =C2=A0 =C2=A0# Create a normal image
> > =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D> 80,
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =C2=A0=
=3D> 30,
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=A0 =
=3D> 10,
> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =3D> =
'giant');
> > $your_random_str =3D '2345';
> > =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> > =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> > =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $image->out=
;
>
> > =C2=A0print " 1 =C2=A0$image_data =C2=A0 2 =C2=A0 $mime_type =C2=A03 =C2=
=A0$random_number 4 $image
> > ";
>
> > =C2=A0 =C2=A0 binmode STDOUT;
> > =C2=A0 =C2=A0 $m->clear_buffer();
> > =C2=A0 =C2=A0 $r->content_type("$image/$mime_type") ;
> > =C2=A0 =C2=A0 $m->print($image_data);
> > =C2=A0 =C2=A0 $m->flush_buffer();
> > =C2=A0 =C2=A0 $m->abort();
>
> I am not sure how you configured HTML::Mason with your site, but
> before you use $m and $r objects under CGI, you should at least
> instantiate them, otherwise they invoke ERRORs for undefined
> variables... the point is sending out the correct content-type header,
> and clearing non-related buffers before and after your image data, and
> printing to STDOUT with binmode to generate the image on the fly.. no
> need for a temporary file, this at least works under Linux box...
>
> lihao
>
>
>
> > ##### I Tried adding this but it doesnt help:
> > $filename1 =3D 'c:\tmp\test.png';
> > open(OUTFILE,">$filename1")|| die 'ERROR : external table not found :'.
> > $filename1."\n";
> > print OUTFILE $image_data;
> > # =C2=A0print OUTFILE out;
>
> > ########
> > Results Errors:
> > 1 =C2=A05=E2=88=9E=CF=83=C3=B7w?=E2=8C=82=C2=AB=E2=89=A4 =C2=A0 =C2=A0 =
=C2=A0 =E2=89=88=E2=95=91=C2=B1L=C3=B2=E2=98=BA- =C2=A0 =C2=A0IEND=C2=ABB`=
=C3=A9 =C2=A0 2 =C2=A0 png =C2=A03 =C2=A0671027 4
> > GD::SecurityImage=3DHAS
> > H(0x18300bc) Can't call method "content_type" on an undefined value at
> > cap.pl li
> > ne 21. =C2=A0(same with clear_buffer and flush_buffer- Hide quoted text =
-
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Does anyone have a working example of a script using Image::Magick (or
the GD::SecurityImage) or OTHER that outputs to a WINDOWS directory ?
This line just doesnt work from the above :

my($image_data, $mime_type) =3D $image->out;

Thank you,

Jack


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

Date: Thu, 3 Jan 2008 13:21:51 -0800 (PST)
From: Jack <jack_posemsky@yahoo.com>
Subject: Re: anyone have a working captcha perl script for windows ?
Message-Id: <03f9db3b-2e0e-497d-a71b-6c4efd67e10c@l6g2000prm.googlegroups.com>

On Jan 3, 12:54=C2=A0pm, Jack <jack_posem...@yahoo.com> wrote:
> On Jan 3, 11:38=C2=A0am, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote=
:
>
>
>
>
>
> > On Jan 3, 10:53=C2=A0am, Jack <jack_posem...@yahoo.com> wrote:
>
> > > On Jan 2, 10:42=C2=A0pm, "lihao0...@gmail.com" <lihao0...@gmail.com> w=
rote:
>
> > > > On Jan 3, 1:12 am, Jack <jack_posem...@yahoo.com> wrote:
>
> > > > > Hi there, I have installed every CPAN Captcha image verification k=
nown
> > > > > and cant get any of them to do a simple task - output to a directo=
ry a
> > > > > set of Captcha images with codes and the code file..you would thin=
k
> > > > > its simple, I tried GD:SecurityImage and this does nothing:
>
> > > > > =C2=A0use GD::SecurityImage;
>
> > > > > =C2=A0 =C2=A0# Create a normal image
> > > > > =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D=
> 80,
> > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =
=C2=A0=3D> 30,
> > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=
=A0 =3D> 10,
> > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =
=3D> 'giant');
> > > > > =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> > > > > =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> > > > > =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $imag=
e->out;
>
> > > > > It runs but you have no way of knowing "where" the images were
> > > > > placed. =C2=A0can anyone reply with a true to life working SIMPLE =
script
> > > > > that just dumps the images and code file ??????
>
> > > > I suppose you were in a web-context, so you need to print out the
> > > > result to STDOUT. you need also send out content-type header before
> > > > sending your image data.. what I did with HTML::Mason:
>
> > > > =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->out;
> > > > =C2=A0 =C2=A0 binmode STDOUT;
> > > > =C2=A0 =C2=A0 $m->clear_buffer();
> > > > =C2=A0 =C2=A0 $r->content_type("image/$mime_type") ;
> > > > =C2=A0 =C2=A0 $m->print($image_data);
> > > > =C2=A0 =C2=A0 $m->flush_buffer();
> > > > =C2=A0 =C2=A0 $m->abort();
>
> > > > If you were using plain-CGI, and your script filename is captcha.cgi=
,
> > > > then you probably can do things like:[sorry I have no experience wit=
h
> > > > plain CGI]
>
> > > > =C2=A0 =C2=A0 {
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 local $|++;
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 my($image_data, $mime_type) =3D $image->=
out;
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 binmode STDOUT;
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print "Content-type=3Dimage/$mime_type";=

> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 print $image_data;
> > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 close STDOUT;
> > > > =C2=A0 =C2=A0 }
>
> > > > or something like that to print out image data to the web with a
> > > > proper content-type(make sure no other data are outputted before
> > > > sending content-type header), and then you can fetch it from the oth=
er
> > > > side with:
> > > > =C2=A0 =C2=A0 <img src=3D"/path/to/captcha.cgi?R=3D..." alt=3D"" />
>
> > > > For me, the random number is generated from outside captcha.cgi, and=

> > > > passed in with an encrypted query string(i.e. R=3D#### as in the abo=
ve
> > > > sample). you can then decrypt it at the beginning of your Perl scrip=
t
> > > > captcha.cgi.. If you like this approach, you need also check out CPA=
N
> > > > for some Crypt:: modules(I am using Crypt::RC4 for this).
>
> > > > BTW. with GD::ImageSecurity, you dont need any temporary file to sav=
e
> > > > the images....
>
> > > > Good luck,
> > > > lihao- Hide quoted text -
>
> > > > - Show quoted text -
>
> > > Hey thanks but that doesnt help - looking for a simple script that
> > > dumps to a DIRECTORY on WINDOWS captcha images and their code file.
>
> > > Your code produces errors when I integrate it:
>
> > > =C2=A0 =C2=A0use GD::SecurityImage;
> > > use HTML::Mason;
>
> > > =C2=A0 =C2=A0# Create a normal image
> > > =C2=A0 =C2=A0my $image =3D GD::SecurityImage->new(width =C2=A0 =3D> 80=
,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 height =C2=A0=
=3D> 30,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =C2=A0 =
=3D> 10,
> > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gd_font =3D> =
'giant');
> > > $your_random_str =3D '2345';
> > > =C2=A0 =C2=A0 =C2=A0 $image->random($your_random_str);
> > > =C2=A0 =C2=A0 =C2=A0 $image->create(normal =3D> 'rect');
> > > =C2=A0 =C2=A0my($image_data, $mime_type, $random_number) =3D $image->o=
ut;
>
> > > =C2=A0print " 1 =C2=A0$image_data =C2=A0 2 =C2=A0 $mime_type =C2=A03 =
=C2=A0$random_number 4 $image
> > > ";
>
> > > =C2=A0 =C2=A0 binmode STDOUT;
> > > =C2=A0 =C2=A0 $m->clear_buffer();
> > > =C2=A0 =C2=A0 $r->content_type("$image/$mime_type") ;
> > > =C2=A0 =C2=A0 $m->print($image_data);
> > > =C2=A0 =C2=A0 $m->flush_buffer();
> > > =C2=A0 =C2=A0 $m->abort();
>
> > I am not sure how you configured HTML::Mason with your site, but
> > before you use $m and $r objects under CGI, you should at least
> > instantiate them, otherwise they invoke ERRORs for undefined
> > variables... the point is sending out the correct content-type header,
> > and clearing non-related buffers before and after your image data, and
> > printing to STDOUT with binmode to generate the image on the fly.. no
> > need for a temporary file, this at least works under Linux box...
>
> > lihao
>
> > > ##### I Tried adding this but it doesnt help:
> > > $filename1 =3D 'c:\tmp\test.png';
> > > open(OUTFILE,">$filename1")|| die 'ERROR : external table not found :'=
 .
> > > $filename1."\n";
> > > print OUTFILE $image_data;
> > > # =C2=A0print OUTFILE out;
>
> > > ########
> > > Results Errors:
> > > 1 =C2=A05=E2=88=9E=CF=83=C3=B7w?=E2=8C=82=C2=AB=E2=89=A4 =C2=A0 =C2=A0=
 =C2=A0 =E2=89=88=E2=95=91=C2=B1L=C3=B2=E2=98=BA- =C2=A0 =C2=A0IEND=C2=ABB`=
=C3=A9 =C2=A0 2 =C2=A0 png =C2=A03 =C2=A0671027 4
> > > GD::SecurityImage=3DHAS
> > > H(0x18300bc) Can't call method "content_type" on an undefined value at=

> > > cap.pl li
> > > ne 21. =C2=A0(same with clear_buffer and flush_buffer- Hide quoted tex=
t -
>
> > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -
>
> Does anyone have a working example of a script using Image::Magick (or
> the GD::SecurityImage) or OTHER that outputs to a WINDOWS directory ?
> This line just doesnt work from the above :
>
> my($image_data, $mime_type) =3D $image->out;
>
> Thank you,
>
> Jack- Hide quoted text -
>
> - Show quoted text -

Hi no worries - I will find another solution .. no need for a response
- thanks all in perl land !


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

Date: Thu, 3 Jan 2008 12:33:51 -0800 (PST)
From: Moti <motic.mail@gmail.com>
Subject: Re: calling perl from html page
Message-Id: <38fb763e-fed5-4dc4-84e9-8dcee6864c57@d21g2000prf.googlegroups.com>

Hi guys,
Thanks for your great detailed answers.

I installed the indigoperl on my window PC.
Afterwards I tried to test it with an guestbook example code that I
found here:
http://www.bin-co.com/perl/cgi/cgi_guestbook.php

I placed the .html files in the htdocs folder (under the indigoperl
installtion folder) and placed the .pl script in the cgi-bin folder.

I think that the server is up and running but when I try to use the
guestbook.html file to run the guestbook.pl script (by pressing the
submit button) it doesnot work.

I suspect that the path pointing to the .pl script is not correct - it
is:   action="\cgi-bin\cgi_guestbook.pl"

Do you have any suggestions ? I dont know what I'm doing wrong
here ...

Thanks in advance, Moti.


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

Date: Thu, 03 Jan 2008 22:00:25 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: calling perl from html page
Message-Id: <87k5mqy68m.fsf@zeekat.nl>

Moti <motic.mail@gmail.com> writes:

> Hi guys,
> Thanks for your great detailed answers.
>
> I installed the indigoperl on my window PC.
> Afterwards I tried to test it with an guestbook example code that I
> found here:
> http://www.bin-co.com/perl/cgi/cgi_guestbook.php
>
> I placed the .html files in the htdocs folder (under the indigoperl
> installtion folder) and placed the .pl script in the cgi-bin folder.
>
> I think that the server is up and running but when I try to use the
> guestbook.html file to run the guestbook.pl script (by pressing the
> submit button) it doesnot work.

We probably need more information that "it doesn't work" for us to help
you. See below. 

> I suspect that the path pointing to the .pl script is not correct - it
> is:   action="\cgi-bin\cgi_guestbook.pl"

Paths in URLs on any system that I know of require forward slashes, i.e:

/cgi-bin/cgi_guestbook.pl

You should also make sure that either all files in /cgi-bin/ or at least
the files ending in .pl are recognized as executable cgi scripts by the
server.

> Do you have any suggestions ? I dont know what I'm doing wrong
> here ...

If the above doesn't help, take a look at the reports in the server's
error log. That's what it's there for. If you can't figure out what's
wrong from the error log, post whatever info you do have (including any
relevant info from the error log) and we'll see if we can help you :)

Aside: http://www.catb.org/~esr/faqs/smart-questions.html

> Thanks in advance, Moti.

Cheers,
Joost.



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

Date: Thu, 03 Jan 2008 13:53:30 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: calling perl from html page
Message-Id: <4rmdnaKhCNPAxODanZ2dnUVZ_qiinZ2d@giganews.com>

Moti wrote:


> I installed the indigoperl on my window PC.

> Afterwards I tried to test it with an guestbook example code that I
> found here:

> http://www.bin-co.com/perl/cgi/cgi_guestbook.php

> I placed the .html files in the htdocs folder (under the indigoperl
> installtion folder) and placed the .pl script in the cgi-bin folder.

> I think that the server is up and running but when I try to use the
> guestbook.html file to run the guestbook.pl script (by pressing the
> submit button) it doesnot work.

> I suspect that the path pointing to the .pl script is not correct - it
> is:   action="\cgi-bin\cgi_guestbook.pl"

Shut down Apache. Be sure to do this.

Move to your Apache "conf" directory. Using a text editor
open your "httpd.conf" file and read slowly and carefully.
There are lots of good instructions within. There a few, very
few "configurations" you need to make to run cgi scripts.
This is discussed within your httpd.conf file.

Save a backup copy of your httpd.conf file. There is already
a "http.default.conf" which serves as a backup, but make
your own backup to be sure all is safe.

Make changes in your httpd.conf file as instructed within
that file. Save this file.

Restart Apache and check your MSDOS window for error messages.

You _must_ stop Apache, edit, then restart Apache.

This is very easy to do once you learn some very basic
configuration needs.

Here is a page which will help you,

http://www.purlgurl.net/manual/howto/cgi.html

Lots of good information on this Apache documentation page.
There are many easy-to-read tutorials on Apache and cgi
available on the web. Have a look at those, as well.

You will do better to begin with a simple "hello world" script.
Indio Perl also contains example scripts in your cgi bin for use.

On your relative path, action="\cgi-bin\cgi_guestbook.pl"
use a full path until you learn what works and what does not.

action="http://localhost/cgi-bin/cgi_guestbook.pl"

Note I use right hand slashes (/). This is what you should
use. You do not need to use Windows left hand (\) slashes
and you should _not_ use those Windows slashes.

Be sure to carefully study the page I link for you.

Only make very small changes and test. Keep this very simple
as you move along. Should you make a lot of changes at once,
you will become lost. There are only three or four changes
you need to make in your httpd.conf file. All are simple.
This is mostly related to "permission" to run a script.

Do not be discouraged. This configuration stuff is very easy
to learn and you will feel silly once having learned. If you
still have problems, you can ask for help here or go over to
the Apache Configuration newsgroup; many experts there.

Clearly your Apache webserver is up and running, you have
accomplished ninety-five percent of your task. Now you only
need to make a few simple tweaks and learn some very simple
and very basic configuration items; very easy to learn.


-- 
Purl Gurl
--
So many are stumped by what slips right off the top of my mind
like a man's bad fitting hairpiece.


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

Date: Thu, 03 Jan 2008 14:10:37 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: calling perl from html page
Message-Id: <3NydnVBg64zCwODanZ2dnUVZ_rqlnZ2d@giganews.com>

Moti wrote:


> I installed the indigoperl on my window PC.

> Afterwards I tried to test it with an guestbook example code that I
> found here:
> http://www.bin-co.com/perl/cgi/cgi_guestbook.php

Moti, I forgot to discuss this for you.

Do not install scripts then test to determine if Apache
is running.

Start Apache through your windows "Start --> Indigo Perl"
program selections. You should find a "start apache" link.

Start Apache. An MSDOS like window should appear on your
desktop or as an icon on your taskbar. Maximize (open)
this window. You should read "Apache..version stuff..running."
Now minimize (do not close) this window down to your taskbar.

Now open a browser, Netscape, MSIE, whatever, and enter this
URL address into your location bar, then "GO" there,

http://localhost

You will or should see an html page which informs
you Apache is successfully running.

Testing Apache for running, is that simple.

You will find this test page in your "htdocs" directory.
Should be index.html in there.

-- 
Purl Gurl
--
So many are stumped by what slips right off the top of my mind
like a man's bad fitting hairpiece.


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

Date: Thu, 3 Jan 2008 14:16:23 -0800 (PST)
From: Moti <motic.mail@gmail.com>
Subject: Re: calling perl from html page
Message-Id: <4efb1ddb-1b13-4d58-b34a-710c01f9140b@m34g2000hsf.googlegroups.com>

Guys, thanks again for your replies.
Joost - here are the logs I got as a repsonse for my trys. Maybe it
conatins a hint..

error.log ->
[Fri Jan 04 00:10:40 2008] [error] [client 127.0.0.1] couldn't spawn
child process: c:/indigo/cgi-bin/cgi_guestbook.pl


access.log ->
127.0.0.1 - - [04/Jan/2008:00:10:40 +0200] "GET /cgi-bin/
cgi_guestbook.pl?name=HOUHL&email=JGK&loc=YGFJKG&comments=GHLKJ HTTP/
1.1" 500 602

Purl Gurl - special thanks for your detailed answer I will try to
follow your instructions ...

Many thanks, Moti.




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

Date: Thu, 03 Jan 2008 14:32:36 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: calling perl from html page
Message-Id: <f9adnUtRw_8b_-DanZ2dnUVZ_j2dnZ2d@giganews.com>

Moti wrote:

You are jumping into this with both feet!

Brave boy!


> error.log ->
> [Fri Jan 04 00:10:40 2008] [error] [client 127.0.0.1] couldn't spawn
> child process: c:/indigo/cgi-bin/cgi_guestbook.pl

Typically, this would read to be a permissions problem
or a path to perl problem.

However, look at your error log entry.


> access.log ->
> 127.0.0.1 - - [04/Jan/2008:00:10:40 +0200] "GET /cgi-bin/
> cgi_guestbook.pl?name=HOUHL&email=JGK&loc=YGFJKG&comments=GHLKJ HTTP/
> 1.1" 500 602

Your next to last entry "500" just before your 602 byte count served.

You should see an html page "Internal Server Error" and other info.
There is something wrong with your script. For a cgi script, the
most common problem is not printing a "content type" header. Next
most common is no path or an incorrect path to perl core.

I will urge you again to use a "hello world" script for testing.
Doing so will instantly verify your server is configured to
serve up cgi scripts. Drop one of these into your cgi-bin,


#!perl (your path to perl is here)

print "Hello World!";


This should appear as a plaintext page, no html.


#!perl (your path to perl is here)

print "Content-type: text/html\n\n";

print "<HTML>Hello World!</HTML>";


This should appear as an html page.

Once again, I urge you to start out testing with a
simple "Hello World" script to confirm Apache is
correctly configured to serve up cgi scripts.


-- 
Purl Gurl
--
So many are stumped by what slips right off the top of my mind
like a man's bad fitting hairpiece.


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

Date: Thu, 03 Jan 2008 14:39:10 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: calling perl from html page
Message-Id: <DuOdnQ7YmL2N-eDanZ2dnUVZ_o-mnZ2d@giganews.com>

Purl Gurl wrote:

> Moti wrote:

(snipped)

> most common problem is not printing a "content type" header. Next


> #!perl (your path to perl is here)

> print "Hello World!";


Very easy to forget a content type. This example
above will cop an internal server error. This
example above should be,


#!perl (your path to perl here)

print "Content-type: text/plain\n\n";

print "Hello World!";


-- 
Purl Gurl
--
So many are stumped by what slips right off the top of my mind
like a man's bad fitting hairpiece.


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

Date: Thu, 3 Jan 2008 14:43:36 -0800 (PST)
From: Moti <motic.mail@gmail.com>
Subject: Re: calling perl from html page
Message-Id: <0dc6d3af-f409-468a-93b2-8dbef5a1f887@d4g2000prg.googlegroups.com>

On Jan 4, 12:32=A0am, Purl Gurl <purlg...@purlgurl.net> wrote:
> Moti wrote:
>
> You are jumping into this with both feet!
>
> Brave boy!
>
> > error.log ->
> > [Fri Jan 04 00:10:40 2008] [error] [client 127.0.0.1] couldn't spawn
> > child process: c:/indigo/cgi-bin/cgi_guestbook.pl
>
> Typically, this would read to be a permissions problem
> or a path to perl problem.
>
> However, look at your error log entry.
>
> > access.log ->
> > 127.0.0.1 - - [04/Jan/2008:00:10:40 +0200] "GET /cgi-bin/
> > cgi_guestbook.pl?name=3DHOUHL&email=3DJGK&loc=3DYGFJKG&comments=3DGHLKJ =
HTTP/
> > 1.1" 500 602
>
> Your next to last entry "500" just before your 602 byte count served.
>
> You should see an html page "Internal Server Error" and other info.
> There is something wrong with your script. For a cgi script, the
> most common problem is not printing a "content type" header. Next
> most common is no path or an incorrect path to perl core.
>
> I will urge you again to use a "hello world" script for testing.
> Doing so will instantly verify your server is configured to
> serve up cgi scripts. Drop one of these into your cgi-bin,
>
> #!perl (your path to perl is here)
>
> print "Hello World!";
>
> This should appear as a plaintext page, no html.
>
> #!perl (your path to perl is here)
>
> print "Content-type: text/html\n\n";
>
> print "<HTML>Hello World!</HTML>";
>
> This should appear as an html page.
>
> Once again, I urge you to start out testing with a
> simple "Hello World" script to confirm Apache is
> correctly configured to serve up cgi scripts.
>
> --
> Purl Gurl
> --
> So many are stumped by what slips right off the top of my mind
> like a man's bad fitting hairpiece.

Hi Gurl Purl,
Thanks to you (and the other forum members) I've got my guestbook page
up & running. The only problem was the 1'st line in my perl script. It
was:  #!/usr/local/bin/perl
When I changed it to:   #!perl -w  the all thing start working ...

So thanks alot for your prompt reply it was very very helpful.

Have a great weekend, Moti.


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 1170
***************************************


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