Webhosting Perl and CGI Scripts: Difference between revisions

From AAISP Support Site
(Created page with "link=:Category:Webhosting You can upload any perl scripts to anywhere on your web site. You can make a cgi-bin directory if you like, but scripts can be in...")
 
(Make a bit more generic, with Perl as an option)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
You can upload scripts to anywhere on your web site. You can make a cgi-bin directory if you like, but scripts can be included anywhere on your web site.
[[File:Couk.png|link=:Category:Webhosting]]


Simple shell scripts can start with #!/bin/sh, #!/bin/bash, or (if you must) #!/bin/csh (but see [https://www-uxsup.csx.cam.ac.uk/misc/csh.html why you should not])


For Perl, the script should start with #!/usr/bin/perl
You can upload any perl scripts to anywhere on your web site. You can make a cgi-bin directory if you like, but scripts can be included anywhere on your web site.


Python is not available.
For perl, the script should start with #!/usr/bin/perl


Particularly for perl scripts uploaded from windows machines, please upload in ASCII mode not BINARY.
Particularly for scripts uploaded from windows machines, please upload in ASCII mode not BINARY.


Within the script, the mail program used for sending mail is /usr/lib/sendmail . You should not use this with the -t argument (which find the From and To in the email) but use -f 'from-email-address' 'to-email-address' in place of the -t argument.
Within the script, the mail program used for sending mail is /usr/lib/sendmail . You should not use this with the -t argument (which find the From and To in the email) but use -f 'from-email-address' 'to-email-address' in place of the -t argument.


A simple mailer is available - see below.
A simple mailer is available - [[Webhosting Form Mailer]]


There are various perl scripts available on the internet, and many books on the subject. You do not have access to php or mysql on the server, and you may have to change the use of sendmail as above.
There are various Perl scripts available on the internet, and many books on the subject. You do not have access to php or mysql on the server, and you may have to change the use of sendmail as above.

==Environment Variables ==


Your scripts have access to the following environment variables :-
Your scripts have access to the following environment variables :-
Line 18: Line 21:
{| class="wikitable"
{| class="wikitable"
| QUERY_STRING
| QUERY_STRING
| The query string (bit after the ? in the
| The query string (bit after the ? in the URI)
URI)
|-
|-
| PATH_INFO
| PATH_INFO
| If after the script there is a / and more
| If after the script there is a / and more of a path then this is that path
of a path then this is that path
|-
|-
| PARAMS
| PARAMS
Line 35: Line 36:
|-
|-
| HTTP_HOST
| HTTP_HOST
| Host: header contents
| Host: header contents Your web site name
Your web site name
|-
|-
| HTTP_AGENT
| HTTP_AGENT
| User-Agent: header contents
| User-Agent: header contents The browser being used
The browser being used
|-
|-
| CONTENT_TYPE
| CONTENT_TYPE
| Content-type: header contents
| Content-type: header contents Used for form postings
Used for form postings
|-
|-
| CONTENT_LENGTH
| CONTENT_LENGTH
| Content-length: header contents
| Content-length: header contents Number of bytes in PUT file
Number of bytes in PUT file
|-
|-
| SCRIPT_NAME
| SCRIPT_NAME
Line 60: Line 57:
|-
|-
| HTTP_REFERER
| HTTP_REFERER
| Referer: header contents
| Referrer: header contents The page this link came from
The page this link came from
|-
|-
| REMOTE_USER
| REMOTE_USER
| If a login was required, this is set to the
| If a login was required, this is set to theuser name
user name
|-
|-
| valign="top" | REMOTE_ADDR
| valign="top" | REMOTE_ADDR
| valign="top" | The remote IP address.
| valign="top" | The remote IP address.This could be an IP6 or IP4 address.
This could be an IP6 or IP4 address.
|}
|}


==Further Notes==

The output from the script must include Content-Type: header and may include other headers then a blank line and the contents. The only exception is a redirection in which case it can just contain the Location: header.

==Error Log==
If you have a file called errlog.txt in the top level, then any error output from any scripts on your site is appended to this file. This is useful for debugging.




==Other Webhosting pages:==
==Other Webhosting pages==
<ncl style=bullet maxdepth=5 headings=bullet headstart=2 showcats=1 showarts=1>Category:Webhosting</ncl>
<ncl style=bullet maxdepth=5 headings=bullet headstart=2 showcats=1 showarts=1>Category:Webhosting</ncl>


Line 80: Line 80:




[[Category:Webhosting]]
[[Category:Webhosting|Perl]]
[[Category:Domains]]

Latest revision as of 17:18, 20 November 2023

You can upload scripts to anywhere on your web site. You can make a cgi-bin directory if you like, but scripts can be included anywhere on your web site.

Simple shell scripts can start with #!/bin/sh, #!/bin/bash, or (if you must) #!/bin/csh (but see why you should not)

For Perl, the script should start with #!/usr/bin/perl

Python is not available.

Particularly for scripts uploaded from windows machines, please upload in ASCII mode not BINARY.

Within the script, the mail program used for sending mail is /usr/lib/sendmail . You should not use this with the -t argument (which find the From and To in the email) but use -f 'from-email-address' 'to-email-address' in place of the -t argument.

A simple mailer is available - Webhosting Form Mailer

There are various Perl scripts available on the internet, and many books on the subject. You do not have access to php or mysql on the server, and you may have to change the use of sendmail as above.

Environment Variables

Your scripts have access to the following environment variables :-

QUERY_STRING The query string (bit after the ? in the URI)
PATH_INFO If after the script there is a / and more of a path then this is that path
PARAMS The parameters (bit after a ; in the URI)
REQUEST_METHOD PUT or GET
REQUEST_URI The URI (web page) requested
HTTP_HOST Host: header contents Your web site name
HTTP_AGENT User-Agent: header contents The browser being used
CONTENT_TYPE Content-type: header contents Used for form postings
CONTENT_LENGTH Content-length: header contents Number of bytes in PUT file
SCRIPT_NAME The name of the script being run
HTTP_COOKIE Cookie: header contents
HTTP_FROM From: header contents
HTTP_REFERER Referrer: header contents The page this link came from
REMOTE_USER If a login was required, this is set to theuser name
REMOTE_ADDR The remote IP address.This could be an IP6 or IP4 address.

Further Notes

The output from the script must include Content-Type: header and may include other headers then a blank line and the contents. The only exception is a redirection in which case it can just contain the Location: header.

Error Log

If you have a file called errlog.txt in the top level, then any error output from any scripts on your site is appended to this file. This is useful for debugging.


Other Webhosting pages

<ncl style=bullet maxdepth=5 headings=bullet headstart=2 showcats=1 showarts=1>Category:Webhosting</ncl>

Webhosting Service page on our main website