in reply to gnuplot and CGI

One approach to this would be to code the graph-producing algorithm as a seperate CGI (for example, called graph.pl). Then, your core CGI script would produce an HTML page containing something like:

<img src="/cgi-bin/graph.pl?param=x&param2=y">
where your parameters contain the variable data you will be graphing. Done this way, your graph.pl can return e.g.:
Content-type: image/jpeg ###ACTUAL IMAGE DATA###

Doing this avoids the need for temp files, as the browser will take the output image data from your graph.pl and display it as an image.

radiantmatrix
require General::Disclaimer;
"Users are evil. All users are evil. Do not trust them. Perl specifically offers the -T switch because it knows users are evil." - japhy

Replies are listed 'Best First'.
Re^2: gnuplot and CGI
by kryberg (Pilgrim) on Nov 09, 2004 at 19:51 UTC
    Thanks for the reply. I think your approach is exactly what I need to do.

    I have not yet worked on the code to send the image data to the browser for this particular project. However, I've tried to do this in the past using GD, got it to work once, deleted that code when it turned out I didn't need it, tried it again and couldn't get it to work.

    What I've tried in the past went something like:
    print STDOUT $query->header(-type=>'image/gif'); binmode STDOUT; print STDOUT $image->gif();
    Is there a better approach?