How to run a .cgi?

Discussion in 'Programming' started by Davidf25sc, Sep 22, 2006.

  1. #1
    Hey, i want to make some experiments with perl scripts, but i dont know anything about them, i just got some examples and as a programer i think i can make my way trough them, what i want to know is, lets say i have a file called hello.cgi, where should i put this file in my server? public_html/cgi-bin/? and how do i run it? lets say my domain is domain.com, so how do i call this hello.cgi? http://www.domain.com/hello.cgi?
    Thank you.
     
    Davidf25sc, Sep 22, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If it is in the cgi-bin directory then you would be calling it through the URL:

    http://www.domain.com/cgi-bin/hello.cgi

    Never forget, a website is organized as a directory structure. This can be real -- as in the directories actually exist on the server -- or artificially created to make URLs easier for people to grasp.
     
    clancey, Sep 22, 2006 IP
  3. Davidf25sc

    Davidf25sc Active Member

    Messages:
    165
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Can i do something like this :
    <?php
    include ("cgi-bin/hello.cgi")
    ?>

    Like, call the hellp.cgi in a php file?
     
    Davidf25sc, Sep 22, 2006 IP
  4. forumposters

    forumposters Peon

    Messages:
    270
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Most servers nowadays are set up so that you can run cgi files in any folder that you want.
     
    forumposters, Sep 23, 2006 IP
  5. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try google to get basic information about CGI. You can write it on Perl, Python, PHP, SH, C and other languages.
    For example my first application for web was writtien on C++ (using Visual Studio) and running under apache on windows :)
     
    intoex, Sep 24, 2006 IP
  6. jacobbannier

    jacobbannier Active Member

    Messages:
    1,155
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    90
    #6
    The CHMod must be 755. That will make it work :)
     
    jacobbannier, Sep 26, 2006 IP
  7. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You cannot do it as an include. If you want to call a perl file, you can invoke it from within a php script and then capture the output before delivering it to the viewer.

    You have two choices. Run it as if from the command line using the exec() or system() function call. Or open the cgi script as if it were a file. This was discussed in this thread http://forums.digitalpoint.com/showthread.php?t=139690 See the last post.
     
    clancey, Sep 26, 2006 IP
  8. Davidf25sc

    Davidf25sc Active Member

    Messages:
    165
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #8
    Oh, ok, thank you all very much, i think i understand it now.
     
    Davidf25sc, Sep 27, 2006 IP