Press Ctrl/Cmd + P to print
or save as PDF

How can I run Perl or CGI scripts?

How can I run Perl or CGI scripts on Windows servers?

You can upload the scripts to /cgi-bin folder.
Here is the path for the perl.exe c:perlbinperl.exe.

Therefore, to run the CGI scripts, please rename all the files to extension .pl . You may relocate all the CGI scripts into the scripts folder.

Please remember to CHMOD them.
Normally you need to CHMOD 755 which you can do via FTP software.

What is a CGI script?

A CGI script is a small program, or script, that runs on the Web server. It usually produces some sort of dynamically-generated Web page, such as a guestbook page or some information pulled from a database.

CGI stands for Common Gateway Interface. It’s simply a mechanism to allow Web servers to run external programs or scripts when requested by a Web browser.

You can write CGI programs or scripts in any programming language you like, as long as the end result is something the server can run. However, CGI scripts are usually written in Perl.

What is Perl?

Perl is a powerful and flexible scripting language. Also, Perl is an interpreted language. This means that you can make changes to a Perl script and see the results immediately (unlike programming in C, where you have to recompile the program each time). This makes Perl highly suitable for CGI scripting.

What does a CGI script actually look like?

Here is a very simple CGI script written in Perl. Don’t worry if you don’t understand it at this point. We’ll explain this script in more detail in a later tutorial!


#!/usr/bin/perl

print "Content-type: text/html\n\n";

print <<END_HTML;

Hello, World!

END_HTML

This CGI script simply displays a Web page containing the text “Hello, World!”.

A CGI script is a file, just like a Web page, or a GIF image. The main difference is that CGI scripts are actually run by the Web server, whereas images and Web pages are simply displayed.

How do I run a CGI script on my Web server?

A CGI script is a file, just like a Web page, or a GIF image. The main difference is that CGI scripts are actually run by the Web server, whereas images and Web pages are simply displayed.

Usually, you will need to upload your CGI scripts to your Web server, just like you upload your Web pages and images (often using FTP). On most Web servers you will need to upload it to the cgi-bin folder on your site.

In other words, once you’ve uploaded the script, you usually need to set its permissions.