Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    How to run a CGI perl script?

    hello to all,

    I am really stuck in a problem.I have learned Perl and HTML and am now moving to learn CGI perl.
    I am able to understand the problem, but am unable to understand how to execute these programs.
    also I am confused that actually the CGI Perl files are saved as only .cgi extention???
    If yes, then what are those programs that have a HTML part linked to a perl program. Those are also not running properly. Opening the HTML page links the perl program, but the program does not run, and the complete program appears on the HTML page itself.
    Please help me out.

    Regards and Thanx in advance.

  2. #2
    New Coder
    Join Date
    Jan 2010
    Thanked 13 Times in 13 Posts
    Tell us more about your setup. Do you have HTTP software, and what is it? Apache is an example HTTP server.

    Put your Perl scripts in your cgi-bin folder, then you can access them by going to that directory. For example, if you put a script named helloworld.cgi in the cgi-bin, you access it like this:

    Then your server will run the script helloworld.cgi. To send data to your script, you can use HTML. Here is part of it:

    <form action="http://www.example.com/cgi-bin/helloworld.cgi" method="post">
    The server has to be configured to run Perl scripts. Your Perl script needs to have the typical shebang (the #! line) if you're on a Unix or Unix-like system. And "Content-type" needs to be the first line in your Perl program (first line of code, after the shebang):

    print "Content-type: text/html\n\n"
    Tell us more about your setup. You need a server to run Perl as a CGI, and it needs to be configured to run Perl scripts.
    Last edited by hey; 11-19-2011 at 05:04 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts