Article #: 51 • Updated: Mon Apr 12 2010 at 12:41 pm
Sooner or later most non-trivial web sites will need one or more custom
programs that run on the server (aka “CGI scripts”). In general we
recommend
that any new scripts be written using the PHP programming language
because
it’s faster, more secure, and more portable than the alternatives.
However, if
you want to run a pre-made script that is written in some other
language, or
you simply prefer to program in another language (like perl, python,
ruby,
tcl, etc) we support that too.
Unlike PHP, which is built in to the web server software itself, scripts
written in other programming languages are run as external programs. In
order
to maintain security an intermediate program called “SafeCGI” is used
which
sets up a secure environment before launching the script. All of this
should
be transparent to you, however.
There is no need to place your CGI scripts in a special directory, but
you can
if you want to. Just keep in mind that you can’t use the name “cgi-bin”
for
this directory because it’s used for cgi scripts shared by all users.
The
location of the script doesn’t really matter as long as it’s in your web
space. What’s important is the filename of the script and the file
permissions.
Any file in your web space that ends with “.cgi” will be treated as a
CGI
script and SafeCGI will attempt to run it. It must be owned by you and
have
execute privileges enabled. The file itself may be a binary executable
(as
long as it’s compatible with our servers), or (more commonly) a text
file
containing a script written in an interpreted language like perl or
python.
For interpreted languages, the first line of the file is generally a
“bang
path”, which tells the operating system which program should be invoked
to
interpret the rest of the code in the file.
Common bang paths include:
#!/usr/bin/perl
#!/usr/local/bin/python
#!/usr/local/bin/ruby
Note that certain filename extensions will force a specific interpreter.
For
example, if your script name ends with “.pl”, perl will be used
regardless of
the bang path. An extension of “.py” will use python, and “.rb” will use
ruby.
–
Islandnet AMT Solutions Group Inc.
Hosting, Domain Registration, PHP, MySQL, Python, Perl, Ruby, Other
CGI’s
since 1993!
Telephone / fax: 1-250-383-0096
Toll free phone / fax: 1-800-331 3055
E-Mail: [email protected]
WWW: http://www.islandnet.com
Live Chat support with Islandnet staff from our website
Follow us on Twitter: islandnetcom