Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Please explain this url

by manishrathi (Beadle)
on Mar 21, 2010 at 20:33 UTC ( [id://829976]=perlquestion: print w/replies, xml ) Need Help??

manishrathi has asked for the wisdom of the Perl Monks concerning the following question:

Following syntax is used to make a callout and populate a textarea with content from options.txt

/cgi-bin/cgi_wrapper.cgi/example_datacapture_callout.pl/options.txt

I am copnfused with this syntax. A URL ends with a file name to be executed. And all the path before that is parent folders. In here, cgi_wrapper.cgi is a file, example_datacapture_callout.pl is also a file and options.txt is a file. How does a file contain other file ? How does this execution work ?

Please explain this.

Replies are listed 'Best First'.
Re: Please explain this url
by Corion (Patriarch) on Mar 21, 2010 at 20:45 UTC

    This mostly depends on your webserver, but many webservers can be configured that if they find an executable file along the way (/cgi-bin/cgi_wrapper.cgi/example_datacapture_callout.pl), they execute that and set $ENV{PATH_INFO} to the rest (options.txt in your case). But as HTTP is a protocol, no URL needs to correspond to anything on-disk anyway.

Re: Please explain this url
by JavaFan (Canon) on Mar 21, 2010 at 22:42 UTC
    A URL ends with a file name to be executed. And all the path before that is parent folders.
    Huh? Why? That's not what the standard says, and that's not how most webservers are configured. It's a basic mistake to assume URLs contain file paths.

    A webserver may do as it damn well pleases when asked for a certain URL. It's not violating any URL related RFC.

      Okey , so in this case, how will the execution of files takes place ? when server encounters cgi_wrapper.cgi, will it execute it and then go to next executable file example_datacapture_callout.pl and then work on next file options.txt ?
      Does it mean that, we can execute multiple executable files at the same time (Like we are executing two files cgi_wrapper.cgi and example_datacapture_callout.pl in this case) ?
      Can we put more executable files in path like cgi_wrapper.cgi/example_datacapture_callout.pl/inline_callout.pl/options.txt ? Will all the files be executed in one callout command ?
      thanks
        when server encounters cgi_wrapper.cgi, will it execute it and then go to next executable file example_datacapture_callout.pl and then work on next file options.txt
        This is a Perl site. We cannot divine some magic that tells us what server you are using, and how it's configured.

        Please consult the vendor of your server, or the manual that came with it.

        On my server (some apache version), the data between the executable path and the first '?' are passed in the environment variable PATH_INFO. The script can then do whatever it wants with this information.

        Here's a little script that proved useful for debugging where different sorts of information is presented to a script

        #!/usr/bin/perl -T use strict; use warnings; use HTML::Entities; print <<EOF; Content-type: text/html <html><head> <title>Environment variables and POSTed data</title> </head> <body> <p> POSTed input data : <blockquote> EOF print encode_entities $_ while (<>); print <<EOF; </blockquote> </p> <form method="post" action="$ENV{SCRIPT_NAME}"> <input name="box1" value="value1"/> <input type="submit" value="Send some data"/> </form> <p> Environment: </p> <table border="1"> EOF foreach my $v (sort keys %ENV) { print qq.<tr><td>$v</td><td><tt>., encode_entities($ENV{$v}), qq.</tt></td></tr>\n.; } print <<EOF; </table> <p> source code for this page: <blockquote> EOF unless (seek DATA,0,0) { print "couldn't read myself\n" } else { print "<pre>"; print encode_entities $_ while (<DATA>); print "</pre>"; } print <<EOF; </blockquote> </p> </body> </html> EOF __DATA__
Re: Please explain this url
by SuicideJunkie (Vicar) on Mar 22, 2010 at 13:45 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://829976]
Approved by GrandFather
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 19:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found