Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic questions about CGI 2

Status
Not open for further replies.

jjsoni

Programmer
Jun 8, 2008
1
US
I am new to CGI and have some confusion.

What is CGI ? Is it a set of standards which must be followed while communicating between server and CGI script ? How does a server know that a particular program script is following CGI standards ? I have seen cgi-bin directory. If I put a script in this directory, does it mean that program is CGI program ? What happens if I put a program in cgi-bin directory, which is not CGI program ? How do I make my perl script a CGI program script ? Where do I mention that this is CGI script and do I have to provide .cgi extnsion to make it a cgi script ? which are the other standards like CGI to run server side programs based on request from a client ? Perl script is used to write CGI programs, can I use java to write CGI script ?

Pls answer all questions

Thanks
 
Hi

jjsoni said:
Is it a set of standards which must be followed while communicating between server and CGI script ?

Yes.

jjsoni said:
How does a server know that a particular program script is following CGI standards ?

It does not know.

jjsoni said:
I have seen cgi-bin directory.

That is web server specific.

jjsoni said:
If I put a script in this directory, does it mean that program is CGI program ?

No. But usually supposed. Restricting the execution of external applications to a specific location is for security.

jjsoni said:
What happens if I put a program in cgi-bin directory, which is not CGI program ?

Nothing special. The program will do what it can. Most probably the web server will detect the absence of HHTP response headers in the executed application's output and will send status 500 ( Internal Server Error ) back to the user agent. But this depends on the web server.

jjsoni said:
How do I make my perl script a CGI program script ?

Use the CGI module. But nothing but you can guarantee that the script will actually act as CGI application.

jjsoni said:
Where do I mention that this is CGI script and do I have to provide .cgi extnsion to make it a cgi script ?

Nowhere. The requirement for a given extension is web server specific. On some operating systems there are no extensions, on other operating systems certain extensions are mandatory for some file types and can not be changed freely. So usually there is no requirement set for file extension. The .cgi is just a habit.

jjsoni said:
which are the other standards like CGI to run server side programs based on request from a client ?

There are few, but none is so widely implemented and used as CGI. For example, FastCGI, SCGI. Also there are web server specific ones. For example, LRWP for Xitami.

jjsoni said:
Perl script is used to write CGI programs, can I use java to write CGI script ?

Yes. The basic requirements for a programming language to be suitable for CGI applications are few :
[ul]
[li]read from standard input[/li]
[li]write to standard output[/li]
[li]read environment variables[/li]
[/ul]
Although it is possible, writing CGI in Java is not common. Just google for java cgi for more.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top