About MartNet MartNet Technical Support
Home Services Support Members Software Contact
Search Support
MartNet WebMail

MartNet WebAdmin

Dialup Access
  Numbers

Domain Name
  Management

MartNet News /
  Status Info

NOC / System Status


Support Topics:
 MartNet WebAdmin
 Dial-up
 Virtual Hosting
 Web Site Construction
 Unix / Linux
 E-Mail
 Internet Chat
 Game Server Services
 Misc. Stuff
 Policies / Legal





FAQ's:
 MartNet WebAdmin
 Dial-up
 Virtual Hosting
 E-Mail
 Game Server Services
 Misc. FAQ's

Links:
 Privacy and Security
 Dial-up
 Web Development
 E-Mail
 Unix / Linux
 Game Server Services
 Misc. Support Links




MartNet Policies
Billing Dept.

Check Domain
Availability:



Using CGI's at Martnet
A brief primer on where to put scripts.

This page covers the following topics:

Introduction

To use your own CGI's on any MartNet server, you need to use our CGI Wrapper, which means the URL that calls the script must follow

Welcome to the Using YOUR custom written CGI's at MartNet Support Page. We have compiled this page specifically for MartNet customers who have Web Hosting accounts with us and are interested in writing their own scripts and programs for use with their Web Site. Failure to follow the guidelines and instructions on this page will result in the inability to run your CGI's. Please read through this page thoroughly before you begin writing your CGI's if possible.

The running of (relatively) unrestricted CGI's on Martnet is made possible through the use of a separate CGI known as a wrapper. We have installed a wrapper called, simply enough, CGIWrap. This program is called like a "standard" CGI through a Web Page, and then runs your CGI, in the process it changes ownership of the process and permissions to the owner of the script (usually, CGI's need to be run as root or with other administrative privileges, which makes it possible for buggy programs to take down the system, or for an unscrupulous programmer to compromise the security of the system and wreak havoc...) Basically, the CGI Wrapper keeps your scripts from doing anything you would not normally be able to do from your Shell account. That's why we say you can run (relatively) unrestricted CGI's. Any program or script you write and can run within your Shell account should be accessible via the Web through the CGI Wrapper. The Wrapper software is necessary to protect the overall security and stability of our Servers, and it also provides extra debugging features which will help you get your scripts and programs running with a minimum of frustration usually associated with developing programs for use over the Web.

Click Here to go to the official CGIWrap Web Page for additional information, source code, and other technical information on how the wrapper works.


Where to put your Scripts:

All of your CGI scripts must be in the correct directory or they will not be allowed to run. The scripts must be placed in the following directory (or within their own directory inside):

     your_user_name/public_html/cgi-bin

The cgi-bindirectory should have been created automatically when we first acivated your account. If it was not, or if you have deleted it, you will need to re-create the directory, either with your FTP program, of from the shell type:

     mkdir ~/public_html/cgi-bin


Set the script's permissions:

The script must be set to be world readable AND executable in order for it to work properly. (most FTP clients do not let you set file permissions to be executable during upload)

To set permissions correctly, type the following command:

     chmod 755 your_script_name.cgi


Running your Scripts through the Wrapper:

When referring to a script in your HTML code (or from within another script) you MUST start the script via our CGIWrap program, which in turn will start your script and allow it to run (if there is a problem with the script, CGIWrap will provide some feedback to let you know why the script couldn't run.) To run your script (through the wrappr,) be sure the URL that calls your script is in the following format:

     a href="/cgi-bin/cgiwrap/your_user_name/YOUR-SCRIPT.cgi"

The exact format of the URL will depend on the script itself, and arguments that need to be passed to the script via the Web Browser. We highly discourage the use of absolute URL's (a URL that includes http://www.hostname.com/...) in your HTML code. Use relative URL's instead (the examples in this page are all relative URL's.) If you use an absolute URL to call the script be sure to use your own Domain Name, if you have one hosted at MartNet, or the proper MartNet Web Server cluster name if you have a personal account with us.

If you have a Virtually Hosted Domain with us, DON'T ever use "martnet.com" in your URL's - Your account resides on a cluster of servers, and may me moved to a different server in the cluster at any time (for maximum speed and reliability for your site.) ALWAYS use your own Domain Name if you must use absolute URL's in your code!

It is absolutely necessary that name your CGI's properly. Your CGI's MUST end in .cgi, otherwise they may not run properly through the wrapper.


Using the Wrapper to debug your scripts:

CGIWrap also has an advanced debugging mode that is very useful when you are developing your CGI's. To use the debugging mode, change the URL that calls the script to the following:

    a href="/cgi-bin/cgiwrapd/your_user_name/YOUR-SCRIPT.cgi"

CGI Wrap provides a wealth of informationabout what your script is trying to do / access/ etc. It does not, however, provide as much information as a good set of programming tools. If you can't get your script to run (even using CGIWrap's debug mode) we recommend you try to get the script running from within a shell using all of our available GNU Development Tools. If you don't know what GNU Development tools are, or how to use them, there are many good books, Web Sites, etc. about programming CGI's in perl,C, C++, and many other languages. Just don't get discouraged. Keep in mind that people go to school for years and still have problems debugging their software...


Other Resources:

The CGI Resource Index- http://cgi.resourceindex.com/
Matt's Script Archive- http://www.scriptarchive.com/
Introduction to CGI's- http://support.martnet.com/content.php?get=58



This Web Site is proudly built upon an Open Source foundation:
Assembled with PHP Powered by Debian Linux Fueled by MySQL
Served by Apache

Home | Services | Support | Members | Software | Contact

MartNet - PO Box 42472 Philadelphia, PA 19101
Copyright 1996 - 2015 MartNet Communications LLC. All Rights Reserved.