CGI Scripts | Interview Questions & Answers

CGI is an acronym, and it stands for Common Gateway Interface. Below I am listing interview questions and answers on CGI scripts that may be asked in company interviews.

CGI Scripts Interview Questions & Answers

Q1. What is a CGI Script?


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

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

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

  • 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 is the POST method more secure as compared to the GET method?

Ans: In the GET method, data is 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 do the CGI scripts know that the form data received has been URL encoded?

Ans: CONTENT_TYPE environment variable.

Q7. What is the function of the 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.

Q11. Why do Programmers prefer to use Perl language for CGI?

Ans: There are many reasons behind the use of Perl language for CGI but we will discuss some important points:

  • As Perl is interpreted language, you can easily do debugging while programming CGI. No compilation is needed to perform each task.
  • Perl is quite a good choice for doing socket programming.
  • Perl decently manages strings by the mechanism of memory allocation and deallocation.
  • Perl has rich functionality for pattern matching.

Q12. What is the one main disadvantage of using Perl for CGI programming?

Ans: Some web applications are meant for only speed. If you want super fast speed for your web application, you must consider programming in a compiled language like C.

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.

You may also like...

2 Responses

  1. Shahbaj says:

    Nice article…

Leave a Reply

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

OWASP API Top 10 - 2023 7 Facts You Should Know About WormGPT OWASP Top 10 for Large Language Models (LLMs) Applications Top 10 Blockchain Security Issues What is Cyber Warfare?