View Full Version : cgi path issue?
leversole
08-13-2002, 11:11 PM
I am new to cgi programming...
I have a small "Hello world" script I am testing out
here is how I am calling it in an shtml file
<!--#exec cgi="test.cgi"-->
This only works if I put the script and the web page in the
same folder. I thought the idea was to put all of your scriptrs together in the cgi-bin folder. I have tried a variety of ways
to call thinking it was a path issue such as...
<!--#exec cgi="eversolenet.com/cgi-bin/test.cgi"-->
What am I doing wrong?
Thanks in advance...
don5408
08-13-2002, 11:20 PM
"<!--#exec cgi="eversolenet.com/cgi-bin/test.cgi"-->
What am I doing wrong?"
Hi. Try referencing the server path to your CGI-BIN folder (/home/username/public_html/cgi-bin/) rather than a URL:
<!--#exec cgi="/home/eversol/public_html/cgi-bin/test.cgi"-->
"I thought the idea was to put all of your scriptrs together in the cgi-bin folder."
Well that's one way of doing it, however that's not absolutely necessary (you can run a CGI script from anywhere) and there are other schools of thought on this issue.
Best wishes
Don
leversole
08-13-2002, 11:27 PM
Thanks for the response! Are the other "schools of thought"
that the script will execute (or be found) quicker if it is
in the same folder?
Leslie
don5408
08-13-2002, 11:49 PM
"Thanks for the response!"
You're welcome!
"Are the other "schools of thought" that the script will execute (or be found) quicker if it is in the same folder?"
Well I don't want to give you the misimpression that I possess a degree in that "school" (I'm just starting 1st grade and if they covered this in CGI Kindergarten I was either asleep or out sick that day ;-) however I don't *think* that speed is an issue here...my (relatively limited) understanding is that it's more a matter of personal preference, and that the main factor is simply what you find more convenient.
All I can tell you *for sure* is that while the script probably wont execute any faster it sure takes less time to type test.cgi than it does to type /home/eversol/public_html/cgi-bin/test.cgi. ;-)
Seriously though, there may be other issues (security, etc) that I'm not taking into account, perhaps someone who *was* awake in school the day they reviewed this topic can fill us both in.
Don
eisforian
12-16-2002, 02:40 AM
> "Seriously though, there may be other issues (security, etc) that I'm not taking into account, perhaps someone who *was* awake in school the day they reviewed this topic can fill us both in."
Don, I'll try :)
There are two ways of executing your CGI script: as an executable command and as a CGI application. The first is done by providing the path to the script via the path to your home directory on the server and using the #exec tag, e.g., "<!--#exec cmd="/home/logical/public_html/cgi-bin/test.cgi"-->". This might produce strange results and depends on how the CGI program has been written -- you might have random "Content-type: text/html" messages appear on your pages.
The latter way will probably give you the result you desire. To call the program as a CGI application you specify the path of the script relative to the web root (meaning everything minus the "http://www.yourdomain.com") and use the #include tag: <!--#include virtual="/cgi-bin/test.cgi"-->
I think I've got this straight -- the official authority (probably) is:
http://httpd.apache.org/docs/howto/ssi.html
don5408
12-16-2002, 03:29 AM
Thanks for the input Ian, however actually the topic we were discussing at that point in the thread really wasn't so much how to run a CGI script but rather where best to run it from.
The hole in my knowledge which I posted an open invitation to anyone inclined to plug (which is still open at this point months later if you have any thoughts on the issue) was in reference to the relative merits (if any) of storing scripts in the cgi-bin folder. We were discussing the fact that despite the fact that here at HostRocket cgi scripts can be executed from any directory some folks tend to store all of their scripts in cgi-bin as a matter of preference, what I wasn't sure about was whether there may be some benefit to doing so that I'm not aware of (as opposed to this simply being a matter of 'old habits dying hard').
To rephrase the question still on the table: what are the potential pros and cons of storing a script in the cgi-bin folder as opposed to just storing it in the same directory as the file one intends on calling it from?
For example say I want to run a script named "example.cgi" in a file named somedoc.shtml which is stored in a "stuff" subdirectory of public_html. Assuming that this is a 'one trick pony' script which I don't plan on using anywhere else on my account (I can see where storing commonly used scripts in cgi-bin could be beneficial strictly as far as remembering where the scripts are stored) what if any upside might there be to uploading the example.cgi file to the cgi-bin folder and using:
<!--#include virtual="../cgi-bin/example.cgi"-->
...as opposed to just uploading it to the same "stuff" folder as somedoc.html and using:
<!--#include virtual="example.cgi"-->
TIA if you (or anyone else) has any input on that subject.
Don
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.