CGI Scripts | Interview Questions & Answers

CGI is an acronym and it stands for Common Gateway Interface. Here are interview questions and answers on CGI scripts.

Q1. What is a CGI Script?


  • CGI stands for Common Gateway Interface.
  • It is a program that runs on the web server.
  • It helps in creating interactive web pages dynamically based on inputs given by the user.
  • CGI scripts can be written in any language.
  • Reside in a special directory in the web server typically “cgi-bin”.

Q2. Which computer language generally used to write CGI scripts? 

Ans: Remember the fact that CGI scripts can be written in any language. CGI scripts are generally written in:

  • Perl scripts
  • C/C++ programs
  • Unix Scripts

Q3. What does the REQUEST_METHOD environment variable specify?

Ans: It specifies whether we are using the GET or the POST method to send data to the server.

Q4. How does the form data get accessed in POST?

Ans: As a continuous stream of bytes from standard input, the number of bytes is stored in the content length environment variable.

Q5. Why the POST method more secure as compared to the GET method?

Ans: In the GET method, data sent as part of the URL. Hence, browser history and logs are stored in plaintext.  While in the POST method, parameters are not stored in browser history and server logs.

Q6. How does the CGI scripts know that the form data as received has been URL encoded?

Ans: CONTENT_TYPE environment variable.

Q7. What is the function of UNIX command “finger”?

Ans: “finger” command is used to display the following information:

  • Login name
  • Full name
  • Office location
  • Phone number
  • Login time
  • Idle time
  • Project files

Q8. List out the differences between an interpreted language and a compiled language.


Interpreted LanguageCompiled Language
An interpreted language is parsed, interpreted and executed each time on run.First source code is compiled, then executed.
Javascript, PythonAssembler, COBOL, C/C++
Less efficientMore efficient
Interpreted language produces the result from programCompiler produces a program written in assembly language

Q9. How does the form data get accessed in GET, and in what form?

Ans: As a continuous stream of bytes from standard input, the number of bytes is stored in the content length environment variable.

Q10. Is there any difference between the CGI script and Java?


The protocol used to run programs on web servers.Java is having its own standard APIs to, run the programs on web servers.
Not very scalable and secure.Object-oriented and secure.
Platform dependent.Platform independent.
No provision for separation between the presentation and business logic.Java defines the clear separation between presentation and business logic.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

2 thoughts on “CGI Scripts | Interview Questions & Answers”


Your email address will not be published. Required fields are marked *