Using GraphApp with the World Wide Web

Can I use GraphApp with the World Wide Web?

Yes, but only under strict circumstances. You and the person who wants to use your GraphApp program must both be using X-Windows, both be connected to the Internet, and the user of your program will have to change some settings to get it to run.

How are programs run on the World Wide Web?

There are several ways to get a program to run on the Web. You can write it in Java, and it will run within a Netscape window, or you can write it in the JavaScript scripting language, and it will run in Netscape or Explorer windows. Or you can run any program which has ".cgi" on the end of its name.

CGI programs are the simplest way to get a program to run on the World Wide Web. A CGI program is just a program which has ".cgi" on the end of its name. For example, "search.cgi" is a valid CGI program name (assuming search.cgi is an executable file, a shell-script or some other program.)

When the user clicks on the CGI program, the web server itself will run the program, not the user's machine. So the CGI program must be executable on the machine where the web pages are coming from.

The CGI program must also be readable and executable to anyone, because when the web server tries to load and run the program, it does so without the permissions of the person who created it.

So I just make my GraphApp program readable and executable?

Yes, but there are a couple of extra things you must do.

GraphApp programs are graphical. When executed they will attempt to make windows appear on the screen, so the user can interact with the program.

Here's the problem:

The program is running on a remote machine, not on the user's machine. So how is the user supposed to see the windows which appear?

How does the user see the GraphApp windows?

If both the user and the host machine are using X-Windows, the answer is simple. X-Windows provides a way for a remote program to pop-up windows on a user's machine. Here's how:

  1. The user must allow the remote machine to pop up windows.
  2. The user must tell the program the name of their display.
  3. Then the user can run the program.

In practice this means the following: Suppose the remote machine is called zeta.cs.su.oz.au and the user wishes to run a program on that machine.

The user types the following on their terminal:

      xhost +zeta.cs.su.oz.au
  
This command allows the remote machine to pop up windows on the user's machine.

Then the user runs the CGI script which runs the GraphApp program. The user would have to somehow tell the program what their DISPLAY variable is, so the program knows where to put the windows.

The user would have to be instructed how to discover the value of their DISPLAY variable (for instance using echo $DISPLAY) and then told to type it into the CGI program somehow.

Probably the easiest way to do this is to have a CGI script which sets its own internal DISPLAY variable to be the same as the user's, and then runs the GraphApp program. The GraphApp program would have the same DISPLAY variable as the CGI program, and would thus send windows to the user's machine.

The user's DISPLAY variable must include their hostname, so it should look something like this: host.cs.su.oz.au:0.0 or else like this: 123.12.0.212:0.0

What other restrictions are there?

Remember that a CGI program is executed by the remote machine, not on the user's machine. Hence the program won't have access to the user's files, only to the files which are on the remote machine.

Additionally, the program is executed by the web server, so if the program needs to change any files, those files must be publically writable.

The other important thing to remember is that running remote programs on X-Windows can be slow. Graphics requests sent over the net are slower the further the user is from the remote machine.