Advanced users with UNIX experience may wish to use the ability to write shell scripts.
The Solaris servers support shell scripting, which are configured in the webserver as CGIs. Hence your shell scripts should all have an extension of .cgi and have their permissions set to 755.
The only interpreter available is BASH, and you should call it by using the following first line in your script:
#! /usr/local/bin/bash
Click on one of the links below for more information.
- What is the location of the system programs?
- What restrictions are there on shell scripts?
- Problems with getting scripts working?
- Do shell scripts have to be placed in a cgi-bin directory?
- What coding guides are available?
What is the location of the system programs?
There is a page on this helpsite that explains the location of the various programs that you may wish to call from your script. See here for more information.
What restrictions are there on shell scripts?
We have disabled some functionality for security reasons. This includes the ability to open network socket connections froma script. This will not work.
All CGIs are sandboxed and chrooted and shell scripts run as a CGI.
Sandboxing is the restriction of CPU usage that any one CGI script can utilise. If somebody writes a bad script, it can only get so big and then will stop growing. This is a protection measure to ensure the service is not affected by others. Chrooting is what the name suggests - Change Root. CGI scripts only have access to the necessary programs they have to on the server to be able to function as they cannot get to the system directories or files because as far as they are concerned the root of the server is your own personal webspace area.
The only other restrictions on CGIs are the standard acceptable usage restrictions as per the blueyonder Acceptable Use Policy.
Problems with getting scripts working?
Like all other programming languages, shell scripting is not supported by blueyonder. This means that, while the languages should work fine, we don't assist you in your coding and will only be able to help you out if your site's config does not work (see below).
If you have any issues with getting your shell script to work, you should do the following:
- Examine the error logs for your site. If you login via FTP [and change "up" a directory from your default directory when you login] and look in the logs/today directory, you can access your error logs. You can also see them in a browser by logging into self care.
- Check the permissions of your script. In 90%+ of cases, scripts fail [giving a 500 Internal Server Error] because the script does not have permissions to execute. Most FTP programs now give you the option to set your permissions. CGI scripts should be set to permissions of 755.
- Debug your code. Download one of the many code debuggers you can get on the web. Change the first line of your shell script to put a "-x" after the path to the shell binary (put a space in between). This will report all the workings of your script and may flag up what the issue is in your logs.
- Get onto the newsgroups. Rename your script to be a .txt file and put it in your site's root directory [the home directory when you login via FTP]. Post a link to this file in blueyonder.discussion.pwp if you want help from fellow BY users.
Do shell scripts have to be placed in a cgi-bin directory?
No. If you wish to put your scripts anywhere in your htdocs/ document root, you can feel free. It is, however, convention to keep them in one place.
What coding guides are available?
There's plenty of coding guides available on the web. The best place to start is somewhere like the Linux Documentation Project