Hi. I am new to CGI and am just starting out trying a few things. I am a PHP/MySQL developer and am comfortable writing XHTML, XML, CSS, JavaScript, and ASP.NET VB. I know pretty much nothing of CGI and would like to learn a bit more. Here are a couple of questions I have to start out with:
In a project I'm working on, there's some code that looks like this:
what exactly is going on here? Is this if statement referencing some file, performing a command, what? what does the [[ ]] mean? why the ";"? what is the "fi" at the end?
Main reason I'm asking about this in particular, because I've looked on the server and there is no file located in /SOME/DIR/ called SOMETHING. There aren't any files on the whole server called SOMETHING. What's this code doing?
Another question I have is I tried this to perform a redirect (something more consistent than "meta refresh" or a javascript redirect:
however, I get the message:
Method Not Allowed
An error has occurred.
I tried putting this file in the "CGI-BIN" and I get:
Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log.
Is this because of some setting I have somewhere on the server that restricts redirects? Also, why won't cgi files work outside of /cgi-bin/? Is that also some kind of setting? Is it possible to get CGI to work outside the CGI-BIN? Is there some other way of performing a server-side redirect on a server like this?
I am curious to learn about this stuff and hoped someone could help. Thanks.
In a project I'm working on, there's some code that looks like this:
Code:
if [[ -x /SOME/DIR/SOMETHING ]];then
/SOME/DIR/SOMETHING INTR001
else
SOMETHING INTR001
fi
what exactly is going on here? Is this if statement referencing some file, performing a command, what? what does the [[ ]] mean? why the ";"? what is the "fi" at the end?
Main reason I'm asking about this in particular, because I've looked on the server and there is no file located in /SOME/DIR/ called SOMETHING. There aren't any files on the whole server called SOMETHING. What's this code doing?
Another question I have is I tried this to perform a redirect (something more consistent than "meta refresh" or a javascript redirect:
Code:
#!/usr/bin/perl
my $URL = "/cgi-bin/main.cgi?INIT";
print "Location: $URL\n\n";
Method Not Allowed
An error has occurred.
I tried putting this file in the "CGI-BIN" and I get:
Server Error
This server has encountered an internal error which prevents it from fulfilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log.
Is this because of some setting I have somewhere on the server that restricts redirects? Also, why won't cgi files work outside of /cgi-bin/? Is that also some kind of setting? Is it possible to get CGI to work outside the CGI-BIN? Is there some other way of performing a server-side redirect on a server like this?
I am curious to learn about this stuff and hoped someone could help. Thanks.