Re: 2 Q's, Google and Me - can you spell it out?

2002-01-10 Thread Henk van Ess

Dear all,

I tried to make some adjustments to the script for Google. I made a form
like this:

html

head
meta name=GENERATOR content=Microsoft FrontPage 5.0
meta name=ProgId content=FrontPage.Editor.Document
meta http-equiv=Content-Type content=text/html; charset=windows-1252
titleNew Page 2/title
/head

body
blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet1.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 /
input type=submit value=1 / Doorzoek alleen de titels van websites
/form

/blockquote
blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet2.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 value=www. /
input type=submit value=2 / Tik een naam van een site, bv.
a href=http://www.voelspriet.nl;www.voelspriet.nl/a en kijk hoe vaak de
site aangehaald wordt door anderen/form

/blockquote
blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet3.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 /
input type=submit value=2 / Bekijk alleen de sites die Google de
afgelopen
drie maanden heeft opgenomen/form

/blockquote
blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet4.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 /
input type=submit value=2 / Bekijk alleen de sites die Google de
afgelopen
zes maanden heeft opgenomen/form

/blockquote

blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet5.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 /
input type=submit value=2 / Bekijk alleen de sites die Google de
afgelopen
12 maanden heeft opgenomen/form

/blockquote

blockquote
form action=http://www.voelspriet.nl/cgi-bin/voelspriet5.cgi; method=get
target=_blank
input type=text maxlength=30 name=q size=20 /
input type=submit value=2 / Voor webmasters: vul uw website in /form

/blockquote

/body

/html

And the cgi's look like this:

voelspriet1.cgi

$| = 1;
$q = $ENV{QUERY_STRING};
$q = join('', grep(/^q=/, split(//, $q)));
$q =~ s/^q=//;
print Location:
http://www.google.com/search?q=allintitle:+$qhl=nllr=lang_nl\n\n;;


voelspriet5.cgi
$| = 1;
$q = $ENV{QUERY_STRING};
$q = join('', grep(/^q=/, split(//, $q)));
$q =~ s/^q=//;
print Location:
http://www.google.com/search?q=$q+as_qdr=y1hl=nllr=lang_nl\n\n;;

Can you tell me if this is ok, since you guys gave me some longer code.

Henk van Ess
www.voelspriet.nl


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Henk van Ess

Sorry, I gave the wrong URL

http://www.voelspriet.nl/cgi-bin/spriet.cgi

What did I do wrong?

 Your script works fine on my server. I get a 404 when I try
 to run your link.
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Bob Showalter

 -Original Message-
 From: Henk van Ess [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 09, 2002 3:19 AM
 To: Bob Showalter; [EMAIL PROTECTED]
 Subject: Re: 2 Q's, Google and Me - can you spell it out?
 
 
 Sorry, I gave the wrong URL
 
 http://www.voelspriet.nl/cgi-bin/spriet.cgi
 
 What did I do wrong?

Can't tell based on the message from the server. Check the following:

1. Is there an error message in your sever error log? I see
you're using Microsoft IIS 5.0, but I don't know anything about
how it logs errors.

2. Does your script run from the command line and produce output?
If I run it on my system, it does.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Camilo Gonzalez

This is a common problem. The heredoc terminator must be on a line all by
itself, no spaces, no tabs. Here you have it preceeded by spaces.

-Original Message-
From: Henk van Ess [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 09, 2002 9:22 AM
To: Bob Showalter; [EMAIL PROTECTED]
Subject: Re: 2 Q's, Google and Me - can you spell it out?


Dear Bob, dear all,

I followed your suggestion and installed Active Perl for a local test. If I
run the script below, I get the following error:

Too late for -T option at C:\spriet.nl

When I remove the first line #!/usr/bin/perl -wT
i get the error:

Can't find string terminator  END_HTMLanywhere before EOF at C:\spriet.pl
line 31

Hope you can help ...

Henk van Ess



#!/usr/bin/perl -wT
use strict;
use CGI qw/:standard/;
use URI::Escape;

# if we came from the form, grab the values and create the URL
if ( param )
{
# get the form data
# see perldoc CGI
my $_prefix = param( 'prefix' ) || '';
my $_search = param( 'search' ) || '';

# untaint it
# see perldoc perlsec
my ( $prefix ) = ( $_prefix =~ /^([a-zA-Z\d\s_:]+)$/ ); #create
appropriate regex
my ( $search ) = ( $_search =~ /^([a-zA-Z\d\s_:]+)$/ ); #create
appropriate regex

# escape characters with special meaning in URIs
# see perldoc URI::Escape
$prefix = uri_escape( $prefix );
$search = uri_escape( $search );
print redirect(
http://www.google.com/search?q=$prefix%20$search; );
}
# otherwise, print the Web page
else
{
print header;
print END_HTML;
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head
titleTest page/title
/head
body
form action=spriet.cgi method=get
input type=checkbox name=prefix value=allintitle: /
All in titlebr /
input type=text name=search /
input type=submit   name=Submit /
/form
/body
/html
END_HTML
}





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Henk van Ess

Ty for your fast answer, but I;m still puzzled. Could you paste the script
and add the proper syntax?  You really would help me with that

Henk van Ess


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Camilo Gonzalez

The last part of your script looks like this

/form
/body
/html
END_HTML
}

It should look like this

/form
/body
/html
END_HTML
}

In other words, the END_HTML token needs to be on its own line with a return
immediately before and after it and no extraneous characters, including
spaces. Does that make sense?

-Original Message-
From: Henk van Ess [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 09, 2002 9:49 AM
To: Camilo Gonzalez; Bob Showalter; [EMAIL PROTECTED]
Subject: Re: 2 Q's, Google and Me - can you spell it out?


Ty for your fast answer, but I;m still puzzled. Could you paste the script
and add the proper syntax?  You really would help me with that

Henk van Ess

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Curtis Poe

--- Henk van Ess [EMAIL PROTECTED] wrote:
 Dear Bob, dear all,
 
 I followed your suggestion and installed Active Perl for a local test. If I
 run the script below, I get the following error:
 
 Too late for -T option at C:\spriet.nl

Since you're running IIS, getting the too late for -T option means that your scripts 
are running
through ISAPI.  This will give you a performance benefit, but it also means that you 
lose the
security benefits of taint checking.  An awful tradeoff, as far as I am concerned.  
You can read a
bit more about this at http://www.perlmonks.org/index.pl?node_id=82619
 
 When I remove the first line #!/usr/bin/perl -wT
 i get the error:
 
 Can't find string terminator  END_HTMLanywhere before EOF at C:\spriet.pl
 line 31
 
 Hope you can help ...

Traps with HERE docs:

1.  The final token (END_HTML), in this case, must be on a line by itself and not have 
any
whitespace before or after it.
2.  It must not have a semicolon after it.
3.  It must have at least one line after it.

Actually, the first point above is not quite true.  The following is quite valid 
(let's pretend
that periods are spaces, for a moment):

.print.END_HERE;
.This.will.be.printed
.And.so.will.this
.END_HERE

That can let you cheat and get around the left justification problem.

Cheers,
Curtis Ovid Poe

=
Ovid on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Henk van Ess

Dear all, 

Again, ty so much for your help. I'm learning a lot about Perl now.

Finally the script is running! Details do matter, don't they?

I have a new problem.

Check

http://www.voelspriet.nl/cgi-bin/spriet.pl

check All in Title en press Submit.

Error:

'd:\www\voelspriet.nl\www\cgi-bin\spriet.pl' script produced no output 

Any ideas, you great minds?

Henk van Ess



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Curtis Poe

--- Henk van Ess [EMAIL PROTECTED] wrote:
 http://www.voelspriet.nl/cgi-bin/spriet.pl
 
 check All in Title en press Submit.
 
 Error:
 
 'd:\www\voelspriet.nl\www\cgi-bin\spriet.pl' script produced no output 

Henk,

Find your error log.  Since you appear to be using ISAPI, it's likely named something 
like
'perlIS-Err.log'.  Send the appropropriate errors from that log and that would be a 
good start.

Another thing to use is insert the following line into your program:

use CGI::Carp qw/fatalsToBrowser/;

This line will send the fatal error messages to your browser so you can see them 
directly without
needing to search for the log.  That line should only be used in testing, though, and 
not in
production!

Cheers,
Curtis Ovid Poe

=
Ovid on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Henk van Ess

What an excellent tip.. My ISP doesn't give me acces to the log right away,
so the browser-trick helped me out!

here's the error:
Software error:
Can't locate object method appropriate via package regex at
d:\www\voelspriet.nl\www\cgi-bin\spriet.pl line 17.






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Curtis Poe

--- Henk van Ess [EMAIL PROTECTED] wrote:
 What an excellent tip.. My ISP doesn't give me acces to the log right away,
 so the browser-trick helped me out!
 
 here's the error:
 Software error:
 Can't locate object method appropriate via package regex at
 d:\www\voelspriet.nl\www\cgi-bin\spriet.pl line 17.

Found your problem:

my ( $prefix ) = ( $_prefix =~ /^([a-zA-Z\d\s_:]+)$/ ); #create
appropriate regex

You appear to have cut and pasted the text directly from the Email.  In this case, 
appropriate
regex should have been part of the comment.  By putting them on the next line (this 
occurs in two
places), you are telling Perl that there is a method called appropriate in a package 
called
regex (this is an alternative method calling syntax that I'm not terribly fond of).

To fix this, either delete this line, or remove the newline after #create so that 
Perl
recognizes appropriate regex as part of the comment:

   ...#create appropriate regex

Cheers,
Curtis Ovid Poe

=
Ovid on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-09 Thread Henk van Ess

Dear all,

It worked! You should have seen my face when I saw the script working for
the first time.

My first Perl script, thanks to architect Curtis and with great help of Bob
and Camilo! Ty all.  I'm looking forward to learn more from you guys.


Henk van Ess
www.voelspriet.nl



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-08 Thread Henk van Ess

Dear Poec or others,

I followed the instructions, but the *.cgi fails to generate an output. What
did I do wrong?

Try www.voelspriet.nl/spriet.cgi to see the error. This is the content of
the script:


#!/usr/bin/perl -wT
use strict;
use CGI qw/:standard/;
use URI::Escape;

# if we came from the form, grab the values and create the URL
if ( param )
{
# get the form data
# see perldoc CGI
my $_prefix = param( 'prefix' ) || '';
my $_search = param( 'search' ) || '';

# untaint it
# see perldoc perlsec
my ( $prefix ) = ( $_prefix =~ /^([a-zA-Z\d\s_:]+)$/ ); #create
appropriate regex
my ( $search ) = ( $_search =~ /^([a-zA-Z\d\s_:]+)$/ ); #create
appropriate regex

# escape characters with special meaning in URIs
# see perldoc URI::Escape
$prefix = uri_escape( $prefix );
$search = uri_escape( $search );
print redirect(
http://www.google.com/search?q=$prefix%20$search; );
}
# otherwise, print the Web page
else
{
print header;
print END_HTML;
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head
titleTest page/title
/head
body
form action=spriet.cgi method=get
input type=checkbox name=prefix value=allintitle: /
All in titlebr /
input type=text name=search /
input type=submit   name=Submit /
/form
/body
/html
END_HTML
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: 2 Q's, Google and Me - can you spell it out?

2002-01-07 Thread Curtis Poe

--- Henk van Ess [EMAIL PROTECTED] wrote:
 Dear all,
 
 They told me that this forum teaches Perl in a friendly atmosphere, so I
 hope you can help me. My name is Henk van Ess and I run www.voelspriet.nl, a
 Dutch site about searchengines (non-commercial).
 
 I'm busy with a form for searching all kind of special operators in search
 engines and I want to do that job with radioboxes.
 
 One radiobox should give the following output:

I'm not sure if you mean radion *button* or *check* box.  I am guessing the latter, 
but what I
present will work either way.
 
 http://www.google.com/search?q(FIXED VALUE)+(VARIABLE)
 
 where FIXED VALUE= allintitle: and the VARIABLE is the search term that the
 user enters.
 
 EXAMPLE:
 
 Say someone searches for the word Perl and checks the radiobox Search title
 only, I will need the output:

Without reproducing the rest of your email, I'll cut to the chase :)  Unless you use 
Javascript,
you are trying to combine to form parameter values into one and you can't do that 
directly from
the form (that I know of).  Here's one way to do this through Perl:

#!/usr/bin/perl -wT
use strict;
use CGI qw/:standard/;
use URI::Escape;

# if we came from the form, grab the values and create the URL
if ( param )
{
# get the form data
# see perldoc CGI
my $_prefix = param( 'prefix' ) || '';
my $_search = param( 'search' ) || '';

# untaint it
# see perldoc perlsec
my ( $prefix ) = ( $_prefix =~ /^([a-zA-Z\d\s_:]+)$/ ); #create appropriate 
regex
my ( $search ) = ( $_search =~ /^([a-zA-Z\d\s_:]+)$/ ); #create appropriate 
regex

# escape characters with special meaning in URIs
# see perldoc URI::Escape
$prefix = uri_escape( $prefix );
$search = uri_escape( $search );
print redirect( http://www.google.com/search?q=$prefix%20$search; );
}
# otherwise, print the Web page
else
{
print header;
print END_HTML;
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head
titleTest page/title
/head
body
form action=test.cgi method=get
input type=checkbox name=prefix value=allintitle: / All in 
titlebr /
input type=text name=search /
input type=submit   name=Submit /
/form
/body
/html
END_HTML
}

It works this way:  if we have no form parameters, print the Web page.  If we have form
parameters, grab them, untaint them, convert any characters that may have a special 
meaning in a
URL, and the do a redirect.  All relevant section have pointers to the correct 
documentation.

Obviously, you'll need more than this, but I hope this is a good starting point.

Hope this helps.

Cheers,
Curtis Ovid Poe

=
Ovid on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]