1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

CGI confusion

  1. May 2, 2007 #1

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I am having trouble understanding what CGI scripts are. What I *think* I know about it is that there is no "CGI" language, and when we say CGI script, we mean something written in Perl or Php or some other language that is run on the server. But I could just be utterly confused.

    I was looking at this example:

    #!/usr/bin/perl -wT
    print "Content-type: text/html\n\n";
    print "Hello, world!\n";

    The 2nd and 3rd lines are written in Perl, I believe. But what is the first? This is just an instruction to the server to tell it the language? And what language is that first line written in? Is it a UNIX OS command? I don't know anything about UNIX, so that may be why I don't know what's going on.

    Thanks!:smile:
     
  2. jcsd
  3. May 3, 2007 #2

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    anyone? I didn't think these were tough questions...
     
  4. May 3, 2007 #3
    CGI (Common Gateway Interface) is a communication protocol that specifies how programs communicate and send information back and forth between a server and client program.
    A CGI script can be written in any language, but in the early days of httpd were commonly written in Perl

    The first line of your Hello World script tells the system where to find the Perl interpreter and is common in all unix shell scripts. Basically it tells the system what interpreter to use to execute the commands contained in the file.

    The #! is called a 'shebang'

    CGI
    CGI on Wikipedia
     
    Last edited: May 3, 2007
  5. May 3, 2007 #4

    Math Is Hard

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Thanks, imabug.

    I just came across that first link you posted this afternoon and it has been helpful. I looked at the Wiki info earlier, but it didn't clear it up for me at all.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: CGI confusion
  1. Equation Confusion (Replies: 12)

  2. Confused with moles (Replies: 2)

  3. Confusing Chem (Replies: 5)

Loading...