LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2014, 11:50 PM   #1
praneethdamera
LQ Newbie
 
Registered: Dec 2013
Posts: 15

Rep: Reputation: Disabled
Smile what is CGI?


Hi,

Im a WebDeveloper, recently i hve joined in a company where CGI is used to develop websites, but im new to it, i hve done in java & php but never known about CGi, can any one help me to know this and also tell me where can i get its tutorials, one more i need to know is when i searched for it in google, it says Perl CGI, C++ CGI, C CGI, CGI, is all of them same or different in writing code & its running environment, im confused about CGI please tell me its details, in my company coding is done in c++ and compiled to CGI, so please tell me where can i get this tutorial.

i need to know about,
file handling, cookies, running external command (like shellscript, doscommands) now, as i will be dealing with embedded system with this.

Please help me,


Thanks for your help in advance,
 
Old 01-04-2014, 12:38 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,339

Rep: Reputation: Disabled
Common Gateway Interface is a standard for having external programs/scripts generate (dynamic) web pages. It basically works like this:
  • A client (web browser) requests a page from a web server
  • If the URL points to a CGI resource, the web server software passes the information to an external program or script using the CGI interface
  • The program/script processes the request, and generates output that is sent back to the web server via CGI
  • The output from the CGI program is passed directly to the client by the web server
CGI is an RFC standard (RFC 3875). The Wikipedia article on CGI isn't too bad and may be easier to understand than the RFC.
 
1 members found this post helpful.
Old 01-26-2014, 10:18 PM   #3
praneethdamera
LQ Newbie
 
Registered: Dec 2013
Posts: 15

Original Poster
Rep: Reputation: Disabled
Actually now im using CGI but my confusion starts when i see a CGI code in different manner ie i use C,C++ program to make a CGI ie i will write a code in C/C++ and compile it and i will get a CGI as an executable file but where as some codes are direct as html does they dont need any compiler at all why are they so...
 
Old 01-26-2014, 11:06 PM   #4
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
Quote:
Originally Posted by praneethdamera View Post
Actually now im using CGI but my confusion starts when i see a CGI code in different manner ie i use C,C++ program to make a CGI ie i will write a code in C/C++ and compile it and i will get a CGI as an executable file but where as some codes are direct as html does they dont need any compiler at all why are they so...
Perl and Python are interpreted languages by design. C/C++ is a compiled language by design.
Software written in an interpreted language exists as a plain text script rather than a binary file. To run that software, you must have a suitable interpreter installed.
To the end user, there is usually no noticeable difference. (except that compiled languages may execute a little faster)
 
Old 01-26-2014, 11:42 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
I'm sorry to have to ask this, but I'm too curious not to. How did you manage to get a CGI programming job (and presumably pass the technical interview) while knowing nothing about CGI?

Last edited by dugan; 01-27-2014 at 12:34 AM.
 
Old 01-27-2014, 03:06 AM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
good old TLA's
CGI
Computer Generated Images

it is a good thing that you included
"used to develop websites"

perl, python, ruby
 
Old 01-27-2014, 03:43 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As Ser Olmy said, try the Wikipedia article; its just the std on how interactive website code needs to work.

As a minor aside, Perl is actually compiled-on-the-fly http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html, as opposed to eg bash which really is interpreted, thus leading to a large difference in speed.
 
1 members found this post helpful.
Old 01-27-2014, 09:34 AM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by John VV View Post
good old TLA's
CGI
Computer Generated Images

it is a good thing that you included
"used to develop websites"

perl, python, ruby
Very funny. Common Gateway Interface. Python and Ruby are never used for it.
 
Old 01-27-2014, 09:26 PM   #9
praneethdamera
LQ Newbie
 
Registered: Dec 2013
Posts: 15

Original Poster
Rep: Reputation: Disabled
i have passed interview for Web Developer using PHP & java(JSP & Servlets).

in my company we also have embedded systems, once when i saw a proj of it where they used CGI for web interface i just showed few mistakes in code so they handed over that web interface to me and asked few updates in that, without knowledge also i had to do it & i hve suceessfully done it but now i wanted to learn CGI completely so while learning i had these doubts.

Thanks to you all for clearing my doubts...

1. Perl is interpreted languages by design. C/C++ is a compiled language by design.
2. Common Gateway Interface. Python and Ruby are never used for it.

So now i conclude that CGI files can be made using Perl or C/C++.

Thanks once again to you all..
 
Old 01-27-2014, 10:05 PM   #10
Shadowmeph
Member
 
Registered: May 2008
Location: West Coast Canada
Posts: 282

Rep: Reputation: 29
I always thought that CGI was Computer Generated Imagery like in Movies but I guess I am wrong.
 
Old 01-29-2014, 12:13 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Depends on context; there's only so many TLAs available ....
 
Old 01-29-2014, 09:59 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by praneethdamera View Post
i have passed interview for Web Developer using PHP & java(JSP & Servlets).

in my company we also have embedded systems, once when i saw a proj of it where they used CGI for web interface i just showed few mistakes in code so they handed over that web interface to me and asked few updates in that, without knowledge also i had to do it & i hve suceessfully done it but now i wanted to learn CGI completely so while learning i had these doubts.

Thanks to you all for clearing my doubts...

1. Perl is interpreted languages by design. C/C++ is a compiled language by design.
2. Common Gateway Interface. Python and Ruby are never used for it.

So now i conclude that CGI files can be made using Perl or C/C++.
...and they can also be made with MANY other programs, INCLUDING Python and Ruby. If you have passed an interview to be a web developer and don't know these things, you are in for a very tough time at your new job.

Also, the word "doubt" and the word "question" mean different things.
 
Old 02-03-2014, 08:11 PM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
If you're "using PHP to build web sites," guess what! You're right now using CGI to do that!

You see, what CGI basically is, is a way to specify that "a particular web-page" consists of a program that is to be executed, with the output of that program being what the user will eventually see. (I could offer a more complete explanation here, but this is the essential idea.)

So ... when you build a web-page "in PHP," that PHP is "a program that is to be executed." The user should never see the PHP source-code: what they see is the output that the PHP code, when executed, produces. And that is what "CGI" ... is.
 
Old 02-03-2014, 09:27 PM   #14
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by sundialsvcs View Post
If you're "using PHP to build web sites," guess what! You're right now using CGI to do that!
Not necessarily. PHP can also be deployed as an Apache module. On Linux, it almost always is.

Python and Ruby are generally never deployed using CGI. Python is deployed using WSGI, and Ruby is usually deployed using the Passenger module (AFAIK for Ruby).

None of these technologies are "CGI". CGI is something very specific.

Last edited by dugan; 02-03-2014 at 09:38 PM.
 
Old 02-04-2014, 01:58 PM   #15
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Granted, a stricter version of "CGI" would imply that the process that serves the web-page content is launched by the (Apache) web server each and every time. Which is one of the "issues" that I decided to try to gloss-over, because it really doesn't matter much in the end. Maybe the programming is built-in to Apache as a module; maybe it's running in a companion process (FastCGI); maybe it's launched every time. But these, to me, are mostly implementation distinctions; variations on "the essential idea," which is: that a program runs (somehow, somewhere), and what you get is its output.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Site redirecting to /cgi-sys/defaultwebpage.cgi sanjay87 Linux - Server 3 05-21-2012 02:05 PM
Cant seem to run any cgi scripts in cgi-bin folder, confused? j.smith1981 Linux - Server 5 02-14-2011 05:38 AM
Nagios, Statusmap.cgi and Trend.cgi NOT FOUND edwardcode Linux - Software 24 06-10-2010 07:45 AM
Nagios: statusmap.cgi & Trends.cgi files missing wlchak Linux - Software 6 10-30-2009 06:47 AM
http://www.burstnet.com/cgi-bin/ads/ad7954a.cgi/3980/RETURN-CODE rverlander LQ Suggestions & Feedback 1 06-07-2002 07:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration