Download to client from a cgi script?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Øystein Johansen

    Download to client from a cgi script?

    Hi,

    (This question may be stupid, but I just can't find the answer...)

    How can I make the browser downlaod a cgi script from /cgi-bin/.
    Obviously I can't make a link to it with <a=href="/cgi-bin/script.cgi>,
    since tha script will be executed then.

    I see how Lutz in PP2E prints the script on the screen, but I want the
    user to get the "save file" message box?

    Same thing. What about a binary file? Printing a binary file with
    getfile.cgi from PP2E is just silly. The surfer must be promped to save.
    So, what I want is a script like getfile.cgi, that downloads insted of
    prints the file.


    (Maybe this is more a HTTP/HTML question than a Python question...)

    Clueless,
    -Øystein

  • John J. Lee

    #2
    Re: Download to client from a cgi script?

    Øystein Johansen <oystein@gnubg. org> writes:
    [...][color=blue]
    > How can I make the browser downlaod a cgi script from
    > /cgi-bin/. Obviously I can't make a link to it with
    > <a=href="/cgi-bin/script.cgi>, since tha script will be executed then.
    >
    > I see how Lutz in PP2E prints the script on the screen, but I want the
    > user to get the "save file" message box?[/color]

    Don't put it in the cgi-bin? There will be other ways, too, all of
    which are entirely dependent on your web server and its configuration.
    Anything regarded by your server as a cgi-script *shouldn't* be
    downloadable, because that would risk security problems. Some servers
    will always regard anything ending in ".cgi" or ".py" or whatever as
    CGI scripts, some will regard anything in a particular directory as
    CGI scripts, some will do other things.

    [color=blue]
    > Same thing. What about a binary file? Printing a binary file with
    > getfile.cgi from PP2E is just silly. The surfer must be promped to
    > save. So, what I want is a script like getfile.cgi, that downloads
    > insted of prints the file.[/color]

    I don't understand any of this paragraph.

    [color=blue]
    > (Maybe this is more a HTTP/HTML question than a Python question...)[/color]

    None of the above: entirely a web server question.


    John

    Comment

    • Matthew Wilson

      #3
      Re: Download to client from a cgi script?

      If you want to trigger the browser to ask 'save this file?' then you
      gotta pass it a Content-Type that will trigger that.

      At the top of your cgi script, get rid of 'Content-Type: text/html\n\n'
      and replace it with 'Content-Type: application/octet-stream' or
      something like that.

      This page:



      describes some IE bugs. Good luck! If you figure it all out, can you
      post a message back here for future reference?




      On Sun, 21 Sep 2003 21:28:46 +0200
      Øystein Johansen <oystein@gnubg. org> wrote:
      [color=blue]
      > Hi,
      >
      > (This question may be stupid, but I just can't find the answer...)
      >
      > How can I make the browser downlaod a cgi script from /cgi-bin/.
      > Obviously I can't make a link to it with <a=href="/cgi-bin/script.cgi>,
      > since tha script will be executed then.
      >
      > I see how Lutz in PP2E prints the script on the screen, but I want the
      > user to get the "save file" message box?
      >
      > Same thing. What about a binary file? Printing a binary file with
      > getfile.cgi from PP2E is just silly. The surfer must be promped to save.
      > So, what I want is a script like getfile.cgi, that downloads insted of
      > prints the file.
      >
      >
      > (Maybe this is more a HTTP/HTML question than a Python question...)
      >
      > Clueless,
      > -Øystein
      >
      > --
      > http://mail.python.org/mailman/listinfo/python-list[/color]

      Comment

      Working...