Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: How to run a CGI perl script?
11-18-2011, 11:35 AM #1
- 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.
11-19-2011, 04:55 PM #2
- 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:Code:http://www.example.com/cgi-bin/helloworld.cgi
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):Code:<form action="http://www.example.com/cgi-bin/helloworld.cgi" method="post">
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.Code:#!/usr/local/bin/perl print "Content-type: text/html\n\n"
Last edited by hey; 11-19-2011 at 05:04 PM.