Perl and cgi-bin
FAQ
What is perl?
Perl is a high-level programming language with an eclectic heritage
written by Larry Wall and a cast of thousands. It derives from
the ubiquitous C programming language and to a lesser extent from
sed, awk, the Unix shell, and at least a dozen other tools and
languages. Perl's process, file, and text manipulation facilities
make it particularly well-suited for tasks involving quick prototyping,
system utilities, software tools, system management tasks, database
access, graphical programming, networking, and world wide web
programming. These strengths make it especially popular with system
administrators and CGI script authors, but mathematicians, geneticists,
journalists, and even managers also use Perl.
What version of perl do you use?
We use perl version 5.005_03 (perl version 5.6.0 is also available)
What is the difference between .pl and .cgi?
There is no difference between using files with either extension.
What path do I have to use?
/usr/bin/perl for perl 5.005_03 (/usr/local/bin/perl for perl
5.6.0)
so at the beginning of your scripts you should have:
#!/usr/bin/perl
What is the path to my home directory?
In the unix/linux file system, the full path to your directory
on our system is /www/db/loginname/cgidirectory (as opposed
to c:\htmfiles\cgistuff, which is the ms dos file system method).
If your scripts ask you to specify the full path to a file or
directory, this is what you will need to use.
What about the path to date and sendmail?
$date = '/bin/date';
$mailprog = '/usr/bin/sendmail';
Does it matter what I call my cgi directory?
No. You can call your cgi directory anything you like, for example
"cgi-bin", "cgibin", "cgidir", so long as the directory is executable.
Uploading
and file permissions |
How do I upload perl scripts?
Perl scripts are uploaded in the same way as any other file you
have on your web site: by using ftp software such as ws_ftp or
cute ftp for pc or fetch or anarchie for mac. However, once the
files have been uploaded you will need to set them so that they
are executable (see next section).
Make sure to upload the files in ascii mode. If you do not do
this, the file will be uploaded in ms dos format and every line
will end with ^M (the dos end of line character). The server will
not be able to interpret the script, and it will fail.
How do I set permissions on executable files?
Perl scripts need to be executable in order to run them on the
server. You can do this using the ftp software you use to upload
your files. Upload the files in the usual way, then perform the
following on the uploaded file:
In WS_FTP: right click on the file and choose "FTP commands",
then "SITE". Type in:
chmod 755 filename.pl
and press OK.
In CuteFTP: right click on the file and choose "Change File
Attributes". In the manual section type 755 and press OK.
In Fetch: click on the file; choose "Remote", "Set
Permissions"; for Owner tick all three boxes, for Everyone
tick Read and Search/Execute; press OK.
In Anarchie: click on the file; choose "FTP", "Send
FTP Command"; type in
site chmod 755 filename.pl
and press OK.
How do I use the form to email gateway?
Insert this code into your html file:
<form method=POST
action="http://www.cia.com.au/cgi-bin/formmail.cgi">
<input type=hidden name="recipient" value="your_login_name@cia.com.au">
<input type=hidden name="subject" value="Whatever
Subject You Wish">
<input type=hidden name="redirect" value="your_reply.html">
(this part is optional)
Form fields as you wish
<INPUT
type=submit value="Submit">
<INPUT type=reset value="Reset">
</form>
More Scripts and Information
|
Where can I get good perl scripts?
There is an excellent collection of useable scripts at Matt's
Script Archive
Where can I get more information?
More information on perl can be found at:
It still doesn't work!
If your script fails to work, please make sure of the following
things before you mail support:
- The path in your perl script is set to #!/usr/bin/perl (#!/home/local/perl
will also work if you have an old script)
- The cgi-bin directory is executable
- The script file itself is executable
- Make sure you have uploaded the files in ascii mode. If you
do not do this, then every line will end with ^M and the server
cannot interpret the script
- The full path to your directory in your scripts is specified
in the form of /www/db/loginname/cgidirectory
|