# CGI scripts

Jigsaw Home / Documentation Overview / Tutorials

They are two ways to setup CGI scripts. The manual way requires that you describe each script to the server. Let's say your script's path relative to the server root is WWW/cgi-bin/myscript. You will first have to create an appropriate org.w3c.tools.resources.FileResource with a org.w3c.jigsaw.frames.CgiFrame instance to wrap your script. See this tutorials to know how to create a resource in Jigsaw.

Then edit the newly created resource, and setup it's command line (the command line the server will use to run your script). Each line of the text field should represent one argument, the first one being the script full path.

You can also register files of a given extension as scripts, by using a specialized indexer.  When required, you can even specify the interpreter to be run to execute the script (for example perl scripts).

In this sample the CGI script is a perl script, as you can see the interpreter location must be specified (in the Interpreter field). Read the CgiFrame reference page for more details on CgiFrame configuration.

Note: Some CGI scripts may have problems if the "current directory" is not set, it is something we can't do in Java, so you may have to wrap your script in another one that set the current directory (by using the cd command).

wrapper.bat:
D:
cd c:\foo\bar
mycgi.exe