+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

CGI Programming Interview Questions and Answers

1
What is CGI?

CGI stands for Common Gateway Interface, and is a mechanism through which a browser is allowed to communicate with programs running on a server. If you look at each word in turn it makes more sense -

  • Common - something that is available to many people, regardless of what software they are using.
  • Gateway - a portal through which two things communicate. In this case, the browser communicates to the server.
  • Interface - this implies that we are providing a "front end" for the application running on the server, which is exactly what it is. You enter information in the form, for example, and this is submitted to the program, just like a windows-style program.
2
What is the main function of fork() in CGI programming?
  • The fork() is used to create a child process and it returns the process identification number to the parent.
  • Child process in this case gets a copy of the variables or the subroutines that are used by the parents.
  • Child process if makes any modification then it gets discarded during the termination of the process and it doesn’t affect the parent process.

unless (fork) {
exec ("command");
}
wait;

3
What is Perl?

Perl is an interpreted language (not compiled, like Java) which is ideally suited for CGI programming. It has its roots in Unix system administration and offers several features like regular expressions and file manipulation which make it extremely powerful. It is learning curve has been described as long and shallow. It is very easy to pick up at first, especially if you are at all familiar with Unix. However, it does take quite a bit of time to become familiar with all the little nuances of the language. For most CGI work, however, these little nuances are not really necessary.

4
What are the reasons that cookie server can’t handle multiple connections?
  • Cookie server stores the cookies or the website data that will be used again and again requested by the client.
  • The reasons that cookie server can’t handle multiple connections are as follows:
  • Cookie server doesn’t support the multiple connections and it discards any connection that tries to connect to the server.
  • CGI programming allows the connection to be made to the server as the server handles all the requests that are coming from the program.
  • CGI programming is done such that it accepts only one connection at a time and it doesn’t accept connections until any previous connection is broken.
  • Separate child process handles the connection individually and then the process is having its own namespace with the copy of the parent’s data.
  • Child process in any case if modifies the data then the changes made disappear the moment the process terminates and the data is not stored with the parent.
5
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 stick to CGI.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.
FOLLOW US