Let us connect you
Let Us Connect You
Using CGI on your web page
Setting file permissions
It's important to make sure that your web files have correct file permissions. The web server requires that all of your HTML files and images, etc. are readable by everybody on the system. When you upload your files to your account, they may or may not get the right permissions. You may have to login to your UNIX shell account to change them.
If you get file permission errors, here's the command you need to use from the UNIX shell. Let's say you've uploaded index.html, but you get an error because you don't have permissions to see it with the web server (this is unlikely to happen, as most FTP programs will upload HTML files with the correct permissions). Use the chmod command to change the file permissions:
$ cd public_html$ chmod 0604 index.html
What you've done here is tell the system that your file should be readable and writable by you, but only readable by others. Now, try to browse again; you should be able to see the pages, if not perhaps something else is wrong, or you need to hit the refresh/reload button.
These are the proper permissions for files and directories to obtain the most security:
| /home/user/public_html | 0701 |
| /home/user/cgi (if applicable) | 0701 |
| All webpage files | 0604 |
| All compiled CGI (gcc) | 0701 |
| All interpreted CGI (perl) | 0705 |
To write out files from a CGI program, create a directory under your home directory. If your CGI program writes out random files, the directory should be set to 0702. If the program writes to specific files, the directory should be set to 0701, and the files should be initially created (ie, by touching them) and then set to 0602. If said files must also be read, and not just written, by a CGI program, the files should be set 0706.
Any directory which should not be publicly available, and which is not part of a live website, should be 0700. Any non-executable file which should not be publicly available, and which is not part of a live website, should be 0600. Any executable file which should not be publicly available, and which is not part of a live website, should be 0700.
Using CGI on your web page
To use your CGI programs, you'll need a CGI directory where the web server can look for your CGI programs. CGI directories are created by request only. To get your own CGI directory, just email our Support Department at Support@SpiritOne.com.
Once our support staff has created your CGI directory, put your finished CGI programs in /home/username/public_html/CGI. Now, to access your CGI program on a web page, use the special URL:
http://www.spiritone.com/cgi-usr/username/progname.pl
Make sure you substitute the name of your CGI program for "progname.pl" in the URL above. The special part of the URL is that the web server knows that "CGI-usr" is a special place where it is okay to run CGI programs.
Important: If you are uploading files with a .CGI extension from your computer to our servers, make sure you transfer the file in Ascii mode. Most FTP software transfers CGI files in binary by default. This will, in effect, break your script.
Using the counter
Here's an example of how to use one of our stock CGI programs to beef up your web page. We have a CGI program which keeps track of how many times your page has been looked at. This program can be used by embedding it in your program using a server-side include.
The program is called counter. It can be found in the standard CGI program repository, which the web server knows is a place where it will allow CGI programs to run. In this case, the first time you look in your CGI directory, you will see the program. In order to make this program useful, you need to be able to embed it in a page. There are several steps you need to do in order to make this happen.
Plug in the server-side include itself. You can put it anywhere in your web page, right in the middle of a line, if you want. Here's exactly how the include would look for the plain old counter program:
<!--#exec cgi="/cgi-usr/username/counterodom"-->This just puts the counter value right where the include sits in your file. If you wanted to put this in context, just drop the include in the middle of a sentence, such as:
<!--#exec cgi="/cgi-usr/username/counterodom"--> people have visited this page.NOTE: You must have your CGI directory in order to install your counter. If you create your own directory named cgi, your programs will not work. After you submit your request for a CGI directory and it is created, you will receive an email from the Support department letting you know it's ready.
