help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: octave script on a web page


From: Francesco Potorti`
Subject: Re: octave script on a web page
Date: Fri, 06 Apr 2007 12:13:16 +0200

Here is a working example of how to set up a web page with a form for
setting some parameters and a button to get the resulting computations
in the form of text and plots:
 <http://wnet.isti.cnr.it/software/damatfrc>.

You have the HTML source and links to the CGI script and the Octave
script.

The html page is a simple FORM (in fact, two independent forms, each
treating a different case) with a SUBMIT button.  When you press it, the
cgi script is called and the form parameters are given to it on the
standard input, one per line, in the form name=value.

The cgi script is there just to avoid the octave script doing something
horrible: it limits memory, disk, process and time consumption and
calls the octave script.  The form has a TARGET attribute pointing to an
inline frame (IFRAME), that is where the html code produced by the cgi
will be rendered.

The octave script reads from standard input, does syntax check using a
regular expression and executes one line at a time, printing the
results.  Note that using syntax check less strict than this can easily
expose you to arbitrary code execution unless you use a chroot in the
cgi script.  The script prints two HTTP lines, a blank line and then
HTML to be rendered in the inline frame.  At the end, it includes an
object containing the plot.  I used an OBJECT instead of an IMG because
the former can host SVG pictures (it could also list a series of
different alternative formats, each falling back to the next if the
client cannot render it).  Parallel execution is handled by generating
unique file names for the plot file and removing from the disk image
files older than some minutes; this is the ugliest part and should be
done in a cleaner way.

All the above is intended as a working example, not as a clean
programming example: there is much left to improve and clean.  The first
thing that comes to mind is that the img file cleaning should not be be
done inside the octave script, but inside the cgi script, by deleting
the oldest image files if their number exceeds a threshold (say, 5
files).

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key


reply via email to

[Prev in Thread] Current Thread [Next in Thread]