Skip to main content
gamedev.net
🔒 Locked

HTML Help

Started by Odoacer Apr 17, 2004 at 1:28 AM 4 replies 300+ views
Original Post
Odoacer
Odoacer
Okay I don''t see anywhere better to put this so here I go (I''ve asked all over the ''net, you guys are my last hope...) How would I get a HTML file to automatically run a CGI script upon loading? The script is meant to print out a directory listing to the accessing HTML page. It''s written in Python and works perfectly. I got it working once but changed some things and i''ve been pulling my hair out trying to get it to work ever since. I think when it worked, it looked something like this: <form name="DirectoryList" method="get" action="/usr/lib/cgi-bin/ci/filemanager. cgi?application/x-www-form-urlencoded">
ChaoticCanuck
ChaoticCanuck
If you want to execute the script on the server before responding to the HTTP request you need CGI access on your system

If you want to set up a link that will be viewed after a page is loaded, my preferred method is to use an image; you pass the script any info you need, and have your script return a 1px by 1px transparent gif. Another method is to use a <link ...> which will get loaded by default depending on how you set it up and the client used to view the site.
Odoacer
Odoacer
Yes, I have CGI access. Like I said, the script works perfectly, my problem is getting the HTML page to call the script automatically when it loads. (before responding to the HTTP request, like you said)
aftermath
aftermath
Let me get this straight... you just want a CGI script to execute on the remote server when the HTML is loaded? You dont want it to output anything onto the page?

If so, then use a <img src="http://server.tld/cgi-bin/foobar" style="display: none;" width="0" height="0" alt="script caller" />


Another alternative is to use JavaScript, somewhere in your JS code have a var SomeImage = new Image("http://.../foobar"); (IIRC, that is how it is done.)

However, if you do want it to output, you will have to give me more information.
Rate me up.
UberGeek
UberGeek
I think he wan''ts to have an HTML page call a CGI script (remotely), take the results from the script, and then include the result inside the HTML page.

You have two options:
1) Use an iframe (bad)
2) Modify the CGI script to add all the extra stuff around it''s output, and just refer to the CGI script directly (good)
Odoacer
Odoacer
Aftermath's < img src> solution works fine. However it seems a bit hackish... I was wondering if there's something more standard I could use.

UberGeek, my CGI script already prints a formatted list. The problem I'm having is trying to refer to the CGI script, like you said. If there's a better way to do this other than < img> tags, I'd love to hear it.

[edited by - Odoacer on April 17, 2004 2:01:57 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.