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

I have a script that uses CGI to handle parameter passing and constructs a webpage from various documents. While this process works fine for static files like:

http://www.myserver.com/cgi-bin/myscript.pl?page=this.shtml&table=that.shtml

...what I would LUV to do is something like:

http://www.myserver.com/cgi-bin/myscript.pl?page=this.shtml&table=http://www.myserver.com/cgi-bin/myscript.pl?page=that.shtml&table=other.shtml

Is it possible to do something like this? Can CGI handle it? Is the moon made of cheese?

TIA

======================
Sean Shrum
http://www.shrum.net

  • Comment on Script call with arguments in a script call with arguments...Possible?

Replies are listed 'Best First'.
Re: Script call with arguments in a script call with arguments...Possible?
by snowcrash (Friar) on May 24, 2002 at 07:05 UTC
    I don't know if I understand your problem correctly. Passing urls as params shouldn't be a problem. Either call the script with a POST request, or, if you really need to put an url inside the url ;) be sure to escape the url passed as a param (using URI::Escape for example). Be sure to escape the reserved characters like ?,&,; etc. - uri_escape() doesn't do that by default.

    snowcrash

      Be sure to escape the reserved characters like ?,&,; etc. - uri_escape() doesn't do that by default.

      Be sure to keep your system up to date (with CPANPLUS for example), because URI::Escape::uri_escape does escape those reserved characters. The default behaviour changed in version 1.16, which was released on August 27th, 2001.

      - Yes, I reinvent wheels.
      - Spam: Visit eurotraQ.
      

Re: Script call with arguments in a script call with arguments...Possible?
by S_Shrum (Pilgrim) on May 24, 2002 at 07:07 UTC

    Sorry...it has come to my attention that my question above is just a bit too vague in it's request.

    I want to be able to pass the second script call to the currently processing script; this will use LWP to get() the page generated by the second script call.

    ======================
    Sean Shrum
    http://www.shrum.net

      You have really answered your own question. Provided your script is run on an account with net access and provided your script can run within the normal CGI restrictions (server timeouts etc) then, yes, you can use LWP to get the second script from within the first.

      Remember, to the OS the site is being hosted on, any CGI program is essentially just a script/program with it's output piped into another program. When you view it like that you can realise that there is little stopping you from doing anything! ;)


      This page is intentionally left justified.

        My past experience with CGI and URI's of this nature was that it couldn't be done in the manner stated above (in a standard URL). The problem was the CGI would rip the second 'nested' arguments as arguments for the first.

        Right? As a result, what must be done to perserve the 'nested' call in its entirity. Let me pose another example

        http://www.mysever.com/cgi-bin/myscript.pl?this=that&tisk=task&test=http://www.mysever.com/cgi-bin/myscript.pl?&tisk=that&this=task&foo=bar

        Note that &foo=bar is meant to be a outer script call argument and not a nested script call argument. So I guess I need to know if I can pass the nested URL as a string that CGI won't rip apart. ala:

        http://www.mysever.com/cgi-bin/myscript.pl?this=that&tisk=task&test='http://www.mysever.com/cgi-bin/myscript.pl?&tisk=that&this=task'&foo=bar

        Yes, I know I can use LWP to process the nested call (this is what I want to do), but how do I pass this into the script call without CGI ripping it apart.

        ======================
        Sean Shrum
        http://www.shrum.net