|
||
What is CGI ?The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers. A plain HTML document that the Web daemon retrieves is static, which means it exists in a constant state: a text file that doesn't change. A CGI program, on the other hand, is executed in real-time, so that it can output dynamic info...
Should I use CGI or JAVA?CGI and JAVA are fundamentally different, and for most applications are NOT interchangeable. CGI is a protocol for running programs on a WWW server. Whilst JAVA can also be used for that, and even has a standardised API (the servlet, which is indeed an alternative to CGI), the major role of JAVA on the Web is for client side programming (the applet). In certain instances t...
Should I use CGI or an API?APIs are proprietary programming interfaces supported by particular platforms. By using an API, you lose all portability. If you know your application will only ever run on one platform (OS and HTTPD), and it has a suitable API, go ahead and use it. Otherwise it is advisable to use CGI.
Do I need to be on Unix/ Linux?No, but it helps. The Web, along with the Internet itself, C, Perl, and almost every other Good Thing in the last 20 years of computing, originated in Unix. Linux originated from UNIX and so the same goes for it.
Do I have to use Perl?No - you can use any programming language you please. Perl is simply today's most popular choice for CGI applications. Some other widely-used languages are C, C++, TCL, BASIC and - for simple tasks -even shell scripts. Reasons for choosing Perl include its powerful text manipulation capabilities (in particular the 'regular' expression) and the fantastic WWW support modules...
What do I need to know about file permissions and "chmod"?Unix systems are designed for multiple users, and include provision for protecting your work from unauthorised access by other users of the system. The file permissions determine who is permitted to do what with your programs, data, and directories. The command that sets file permissions is chmod. Web servers typically run as user "nobody". That means that, setting aside s...
What is HTTP (HyperText Transfer Protocol)?HTTP is the protocol of the Web, by which Servers and Clients (typically browsers) communicate. An HTTP transaction comprises a Request sent by the Client to the Server, and a Response returned from the Server to the Client.
What environment variables are available to my application?Save it with any name and run it on your browser. The script returns the default Environment variables. Five important environment variables are available to your CGI script to help in identifying the end user. HTTP_FROM This environment variable is, theoretically, set to the email address of the user. However, many browsers do not set it at all, and most browsers that do ...
Can I get the email of visitors?The best information available is the REMOTE_ADDR and REMOTE_HOST, which tell you nothing about the user. Techniques such as "finger@"are not reliable, are widely disliked, and generally serve only to introduce long delays in your CGI. Better - as well as more polite -just to ask your users to fill in a form.
Can I trace where a user has come from/is going to?HTTP_REFERER might or might not tell you anything. By all means use it to collect partial statistics if you participate in (say) an advertising banner scheme. But it is not always set, and may be meaningless (eg if a user has accessed your page from a bookmark, and the browser is too dumb to cope with this). The HTTP protocol forbids relying on Referrer information for fun...
What are STDERR and STDIN and STDOUT ?In a CGI environment, STDERR points to the server error log file. You can take this to your advantage by outputting debug messages, and then checking the log file later on. Both STDIN and STDOUT point to the browser. In actuality, STDIN actualls points to the server which interprets the client (or browser's) request and information, and sends that to the script. In order t...
How do I generate separate pages for Netscape vs. the rest of the world?You can have your CGI script determine whether your script is being accessed by Netscape by using the environment variable HTTP_USER_AGENT. Here is an example:
How come when I run it from the command line, my CGI works, but not from the browser?This most likely is due to permission problems. Remembering your server is probably running as "nobody", "www", or a process with very minimal privileges. As a result, it will not be able to execute your script unless it has permissions to do so.
How come my CGI runs fine but doesn't manage to write its output files?Again, this has to do with Permissions! The server cannot write to a file in a certain directory if it does not have permissions to do so. You need to make sure that the directory which you are writing to can be written to by the world. If not, do a chmod 777.
How do I check for syntax errors in my script?Load PERL. exe from the numerous sites it is available on, on the CGI internet. Type in the following command from your PERL prompt:
How can I call a CGI without using a <FORM> tag?Domain Name Registration | Linux Web Hosting | Reseller Web Hosting | Free Web Hosting | Free Resource Directory
|
|