Saving information with Web pages
Web servers are stateless. This make it hard, or impossible
to save information.There are a number of techniques that can be
used to help:
-
save in /tmp (UNIX will let "nobody" access this space. The problem
is that this is temporary space, and can be space broomed at any time.)
-
code all information in the web page. Then have the user save and restore
the page. You will probably want to use hidden values to hide much
of the information.
-
email the information. Either the web page or the CGI can email the
data. If it is to be processed by a human, the recipient can
save the mail item. If this is to be automated, eamil to an account/machine
with a .forward file. On UNIX this can invoke a program.
For example if the .forward file says "cat ~/email" the mail will be saved
in a file called email in that user's space. This would get overwritten,
so you would probably like something more like this. "/home/my-id/bin/save-mail.pl".
And then save-mail.pl would be: (copy from http://vclass.cs.ndsu.nodak.edu/~juell/test/mail-save.pl)
-
have a server return a text image of the data for the user to save.
This can then be sent to the server by a page with a "browse" item.
-
use a data base. The web page would have a version of sql commands
embedded or the cgi would have the sql commands. The data base would
have the permissions set to allow the web access to save.
-
save into a file with permissions set to 777. This is basically a
bad idea. It is large security risk. It normally can not be used
on machines that also have public logins.
-
run a copy of a server with a special port as a user program.
This is a reasonable solution, since it can only access the user space,
but then can read and write in the user space. The problem is that
to restart on boot or failure, commands have to entered at the system
level.
-
chmod the cgi to the user which you want to cgi to run as.
chmod 5711 doit.cgi
will allow the server running as "nobody" to run as you.
This will not work with a perl program. For them you need a c program
wrapper. This is a little program to call your perl program.
PLJ 7/12/99