Strange behavior in a Perl CGI script 
Author Message
 Strange behavior in a Perl CGI script

How can a Perl CGI script act like a directory?  I've looked through
my textbooks, but haven't found any reference to this - yet that's
just what a script I've downloaded seems to be doing.

It's accessing another file by referring to itself as a directory, eg.
http://www.*-*-*.com/

I'm very confused, can somebody give me an idea of what's going on?



Mon, 17 May 2004 00:20:45 GMT  
 Strange behavior in a Perl CGI script

Smiley> How can a Perl CGI script act like a directory?  I've looked through
Smiley> my textbooks, but haven't found any reference to this - yet that's
Smiley> just what a script I've downloaded seems to be doing.

Smiley> It's accessing another file by referring to itself as a directory, eg.
Smiley> http://www.myserver.com/cgi-bin/myscript.cgi/thisdocument.doc

Smiley> I'm very confused, can somebody give me an idea of what's going on?

First, "comp.lang.perl" is no longer an authorized group. If your
server carries it, they are in error.

Second, look at any Perl CGI text that talks about $ENV{PATH_INFO}.  You'll
see that your CGI script can be treated like a directory, and any path
following the directory is included in the environment variable.  In
particular, search google for:

        site:stonehenge.com $ENV{PATH_INFO}

and you'll see the columns that I've written that talk about it.

Hope that helps.  And tell your news admin that comp.lang.perl
has been dead since 1995, by consensus decree.

print "Just another Perl hacker,"

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Mon, 17 May 2004 00:39:45 GMT  
 Strange behavior in a Perl CGI script
[
  comp.lang.perl removed from Newsgroups header since it
  still exists only on misconfigured news servers.

  Other newsgroups also removed -- I avoid crossposting.

  This is OT in clpm, and belongs in ciwac. Followups set.
]

On Wed, 28 Nov 2001 23:20:45 GMT, Smiley said:

Quote:
>How can a Perl CGI script act like a directory?  I've looked through
>my textbooks, but haven't found any reference to this - yet that's
>just what a script I've downloaded seems to be doing.

>It's accessing another file by referring to itself as a directory, eg.
>http://www.myserver.com/cgi-bin/myscript.cgi/thisdocument.doc

>I'm very confused, can somebody give me an idea of what's going on?

Have a look at `perldoc CGI` and the paragraph on path_info().

Depending on your web server, the myscript.cgi script will find this
information (ie, /thisdocument.doc ) in the PATH_INFO environment
variable, though better, via the path_info() CGI method.

For reference, you might want to look at:

   http://hoohoo.ncsa.uiuc.edu/cgi

HTH,

Cheers,
Damian



Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub



Mon, 17 May 2004 00:54:14 GMT  
 Strange behavior in a Perl CGI script
What would be the point in having www.site.com/script.cgi/this.filename ?

It's no different to script.cgi?this.filename really... all it does is uses
$ENV{'PATH_INFO'}
 instead of $ENV{'QUERY_STRING'}

A more useful approach is to make the script the directory index, then you
can do this:
www.mysite.com/?this.filename

In the above example, script.cgi is the directory index, so you don't need
to put the filename in..
I do this quite a lot..  makes it harder for someone to hack your script if
they don't know what it's called...
--
Regards,
Chris

---- -Begin Xmas Signature------


split//=>'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'.
'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////';





Mon, 17 May 2004 02:24:01 GMT  
 Strange behavior in a Perl CGI script

Quote:
> What would be the point in having www.site.com/script.cgi/this.filename ?

Basically, when you tried to save it from a browser, instead of saving as
'script.cgi', it would be saved as 'this.filename'

Quote:
> It's no different to script.cgi?this.filename really... all it does is
uses
> $ENV{'PATH_INFO'}
>  instead of $ENV{'QUERY_STRING'}

> A more useful approach is to make the script the directory index, then you
> can do this:
> www.mysite.com/?this.filename

> In the above example, script.cgi is the directory index, so you don't need
> to put the filename in..
> I do this quite a lot..  makes it harder for someone to hack your script
if
> they don't know what it's called...
> --
> Regards,
> Chris



Mon, 17 May 2004 03:03:37 GMT  
 Strange behavior in a Perl CGI script

Quote:

> What would be the point in having www.site.com/script.cgi/this.filename ?

one useful answer is in the CGI FAQ.

Quote:
> It's no different to script.cgi?this.filename really... all it does is uses
> $ENV{'PATH_INFO'}
>  instead of $ENV{'QUERY_STRING'}

it's very different.  the URL parsing and filename translation happen
differently, and user agents regard the URL differently.

--

CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



Mon, 17 May 2004 07:03:20 GMT  
 Strange behavior in a Perl CGI script
On Thu, 29 Nov 2001 17:38:48 +1100, "Skeleton Man"

Quote:

>I see you reared your ugly head again...
>I thought by leaving c.i.w.a.c I wouldn't have to worry about you
>criticising my posts...

>Crawl back in the hole you came from...

Since you seem to be responding to brian d foy, one
of the most knowledgable and helpful denizens
of Usenet it has been my privilege to "meet",
this message marks you an idiot and therefore
suitable for my killfile.  I can only assume brian
has criticised you for being an idiot.

*Plonk*

Helgi Briem



Mon, 17 May 2004 11:41:15 GMT  
 Strange behavior in a Perl CGI script
I've had enough of his criticism..
Another group is used to post to he had something negative to say about just
about ANYTHING I posted..

He just likes to make himself look big and thinks he's the world's greatest
programmer...

I don't have a problem with him as such, just his general attitude towards
methods of learning..

Someone new posts a question, he sends them straight to perldoc, whereas I
prefer to give them some brief assistance, THEN suggest that further
information can be found at perldoc...

I am not saying that his methods are wrong, far from it..
But what I am saying is there are more friendly ways of putting his
expertise across than to snap at and flame me every chance he gets..

Quite frankly though, if he stops critising me, I don't care what he thinks
of my methods and whatever else, so long as he's out of my hair...

As I was informed, if you post to Usenet, you are asking for the opinion of
others.. those were his words actually..

So I'm just expressing my right to an opinion and the right to free speech..

If you want to discuss ignorance, let's do...

--
Regards,
Chris

---- -Begin Xmas Signature------


split//=>'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'.
'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////';





Mon, 17 May 2004 11:50:48 GMT  
 Strange behavior in a Perl CGI script
On Thu, 29 Nov 2001 21:50:48 +1100, Skeleton Man

Quote:

> I've had enough of his criticism..

Boo hoo.

Quote:
> Another group is used to post to he had something negative to say about just
> about ANYTHING I posted..

And is "the System" after you, as well?

Quote:
> He just likes to make himself look big and thinks he's the world's greatest
> programmer...

I think you must be talking of someone else. Maybe you're talking
about a Brian, not about brian. The brian who posts here certainly
doesn't fit your description even though he has more right than most
to feel he's a great programmer.

Quote:
> I don't have a problem with him as such, just his general attitude towards
> methods of learning..

Yes, you made that quite clear by telling him to "crawl in a hole".

Quote:
> Someone new posts a question, he sends them straight to perldoc, whereas I
> prefer to give them some brief assistance, THEN suggest that further
> information can be found at perldoc...

Spoonfeeding is usually frowned upon for a reason. This has been discussed
here way before you even knew how to spell perldoc.

Quote:
> I am not saying that his methods are wrong, far from it..

You're just telling him to "crawl in a hole".

Quote:
> But what I am saying is there are more friendly ways of putting his
> expertise across than to snap at and flame me every chance he gets..

Like telling someone to "crawl in a hole".

I hope you're seeing a pattern here...

Quote:
> Quite frankly though, if he stops critising me, I don't care what he thinks
> of my methods and whatever else, so long as he's out of my hair...

Killfile him and be done with it. Just stop whinging.

Quote:
> As I was informed, if you post to Usenet, you are asking for the opinion of
> others.. those were his words actually..

Words to Usenet by.

Quote:
> So I'm just expressing my right to an opinion and the right to free speech..

Why do you have to attack a respected member of this community in
the process?

Quote:
> If you want to discuss ignorance, let's do...

Let's not.

Cheers,
Bernard



Mon, 17 May 2004 11:57:35 GMT  
 Strange behavior in a Perl CGI script

Quote:

> I see you reared your ugly head again...
> I thought by leaving c.i.w.a.c I wouldn't have to worry about you
> criticising my posts...

> Crawl back in the hole you came from...

There's really no need to insult Brian.  He's a regular poster on clpm,
alt.perl and ciwac.  All he's doing is ensuring that misleading
information is not perpetuated.  All you're doing here is displaying
your own insecurity.  If Brian is wrong then tell him, I'm sure he can
take the criticism.

By insulting regular posters you're only making matters worse for the
rest of us.  This is one reason that Larry Wall (amongst other perl
gurus) no longer graces these newsgroups.

Cheers

Paul



Mon, 17 May 2004 11:10:15 GMT  
 Strange behavior in a Perl CGI script
On Thu, 29 Nov 2001 22:09:14 +1100, Skeleton Man

Quote:

> That's not even worth a reply...

> hmm..  maybe I'll just post a message to all the major groups stating that
> I'm an idiot....  I have nothing to lose..

Sounds like a plan.

Cheers,
Bernard



Mon, 17 May 2004 12:09:51 GMT  
 Strange behavior in a Perl CGI script

[I'm snipping extraneous groups here...]

On Nov 29, Helgi Briem inscribed on the eternal scroll:

Quote:
> On Thu, 29 Nov 2001 17:38:48 +1100, "Skeleton Man"


[a heap of abusive rubbish, evidently]

Quote:
> Since you seem to be responding to brian d foy, one
> of the most knowledgable and helpful denizens
> of Usenet it has been my privilege to "meet",

Hear, hear...

Quote:
> this message marks you an idiot and therefore
> suitable for my killfile.

and adds further confirmation to my decision of a couple of weeks back
to killfile this idiot.


Mon, 17 May 2004 13:54:44 GMT  
 Strange behavior in a Perl CGI script
Quote:

> What would be the point in having www.site.com/script.cgi/this.filename ?

Did you follow Randal's advice posted elsewhere in this thread?

Perhaps you'd like to see
http://www.stonehenge.com/merlyn/WebTechniques/col18.html
(among others) for more info.



Mon, 17 May 2004 14:45:58 GMT  
 Strange behavior in a Perl CGI script


Quote:
> First, "comp.lang.perl" is no longer an authorized group. If your
> server carries it, they are in error.

Shoot self in foot error in cross post :-))

--

Stuart Gall
------------------------------------------------
This message is not provable.



Mon, 17 May 2004 20:27:13 GMT  
 Strange behavior in a Perl CGI script

Quote:

>I am not saying that his methods are wrong, far from it..
>But what I am saying is there are more friendly ways of putting his
>expertise across than to snap at and flame me every chance he gets..

>So I'm just expressing my right to an opinion and the right to free speech..

But if you post something that is, in fact, an error, then the bad
information should be corrected.

Quote:
>>> It's no different to script.cgi?this.filename really... all it does is uses
>>> $ENV{'PATH_INFO'}
>>>  instead of $ENV{'QUERY_STRING'}

>>it's very different.  the URL parsing and filename translation happen
>>differently, and user agents regard the URL differently.

That is not a flame against you.  It is a simple statement of fact.
Stating "the use $ENV{PATH_INFO} is no different than $ENV{QUERY_STRING}"
is incorrect, and his correction of your misunderstanding is not an insult.
        -Joe

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



Mon, 17 May 2004 21:14:31 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Strange behavior in a Perl CGI script

2. Very strange behavior firing off ftp from a perl script

3. Strange behavior with CGI.pm, Javascript

4. strange behavior from cgi inside protected directory

5. PERL 5 vs PERL 4 - strange socket behavior

6. Perl/CGI setuid script displays odd cvs checkout behavior

7. Some strange perl behaviors (bugs ?)

8. Strange behavior using Perl's system() function to query SQL Server with osql

9. Win32::DDE::Client strange behavior, perl gives run-time error

10. Win32::DDE::Client strange behavior, perl run-time error

11. strange perl semop behavior

12. Strange behavior in do while loops in perl 5.00503

 

 
Powered by phpBB® Forum Software