I just signed up to this list so please forgive me if a similar item has
been discussed before. I'm currently working on a project that works as follows: 1. Submit parameter values over a WWW form 2. a PERL/CGI script parses the data, opens OCTAVE and pipes in the data 3. OCTAVE opens an m-file, uses the data and lsode to solve some diff. eqs. 4. OCTAVE output a plot as a pbm file using gnuplot 5. ppmtogif is used to convert the pbm to gif format 6. The output is displayed in a web browser. I successfully have done this using MATLAB/GNUPLOT but I am having some difficulty with the OCTAVE implementation. When I run the cgi script from the unix command line, everything works fine. But when I call the cgi from the web browser, my pbm and gif files have file size 0 (zero). I expect it has something to do with permissions, but can't solve the mystery. Yes, the output directories have 777 permissions (like I said, it works with MATLAB). Here's a list of commands being sent to OCTAVE through the pipe: set term pbm set output "$output_ppm" cd $mfiles A0=$A0; A1=$A1; A2=$A2; B0=$B0; B1=$B1; B2=$B2; B3=$B3; w=$w; K=$K; pilot; exit where $XX are previously defined perl variabless and pilot is my m-file (below) global A2 A1 A0 B0 B1 B2 B3 K w function xdot2=f2(x,t) global A2 A1 A0 B0 B1 B2 B3 K w xdot2(1)=x(2); xdot2(2)=-A1/A2*x(2)-A0/A2*x(1)+K/A2*(B0+B1*t+B2*t^2+B3*sin(w*t)); endfunction function xdot1=f1(x,t) global A2 A1 A0 B0 B1 B2 B3 K w xdot1(1)=-A0/A1*x(1)+K/A1*(B0+B1*t+B2*t^2+B3*sin(w*t)); endfunction if A2 == 0 taut = 10*A1/A0; x = lsode("f1", [0], (t = linspace (0, taut, 200)')); y = x; else taut = 10*sqrt(A2); x = lsode("f2", [0; 0], (t = linspace (0, taut, 200)')); y = x(:,1); end set title "Dynamic Response" set xlabel "Time" set ylabel "Output" set border set nogrid set nokey plot(t,y) Also, when just using GNUPLOT, I can use the size property to scale the image. But in OCTAVE, size has another meaning. Is there some way to scale the output? Any help would be greatly appreciated. Jarrett Campbell [hidden email] |
Jarrett,
If you are using apache or similar Web server have a look at the error log file and see if it contains a clue to your problem. I think you are right to suspect something like file/directory permissions as your CGI script runs as user 'nobody' (or simliar user as specified in the Web server configuration file). You could also make the process a little easier by using gnuplot 3.6 which lets you have a gif terminal. i.e. gset terminal gif and avoids the pbm to gif conversion. To size the gif try something like: gset terminal gif size 640,480 John Judge Telecommunications and Information Techonology Research University of Wollongong email : [hidden email] phone : +61 42 21 4630 fax : +61 42 21 3236 > From [hidden email] Fri Nov 21 06:58 EST 1997 > Resent-Date: Thu, 20 Nov 1997 13:56:19 -0600 > X-Sender: [hidden email] > X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.3 (32) > Date: Thu, 20 Nov 1997 13:52:11 -0600 > To: [hidden email] > From: "W. Jarrett Campbell" <[hidden email]> > Subject: Running Octave through a WWW server > Mime-Version: 1.0 > Resent-Message-ID: <"T7yFwNdVWoI.A.v1G.jXJd0"@bevo.che.wisc.edu> > Resent-From: [hidden email] > X-Mailing-List: <[hidden email]> > X-Loop: [hidden email] > Resent-Sender: [hidden email] > Sender: [hidden email] > > I just signed up to this list so please forgive me if a similar item has > been discussed before. I'm currently working on a project that works as > follows: > > 1. Submit parameter values over a WWW form > 2. a PERL/CGI script parses the data, opens OCTAVE and pipes in the data > 3. OCTAVE opens an m-file, uses the data and lsode to solve some diff. eqs. > 4. OCTAVE output a plot as a pbm file using gnuplot > 5. ppmtogif is used to convert the pbm to gif format > 6. The output is displayed in a web browser. > > I successfully have done this using MATLAB/GNUPLOT but I am having some > difficulty with the OCTAVE implementation. > > When I run the cgi script from the unix command line, everything works > fine. But when I call the cgi from the web browser, my pbm and gif files > have file size 0 (zero). I expect it has something to do with permissions, > but can't solve the mystery. Yes, the output directories have 777 > permissions (like I said, it works with MATLAB). > > Here's a list of commands being sent to OCTAVE through the pipe: > > set term pbm > set output "$output_ppm" > cd $mfiles > A0=$A0; > A1=$A1; > A2=$A2; > B0=$B0; > B1=$B1; > B2=$B2; > B3=$B3; > w=$w; > K=$K; > pilot; > exit > > > where $XX are previously defined perl variabless and pilot is my m-file > (below) > > global A2 A1 A0 B0 B1 B2 B3 K w > > function xdot2=f2(x,t) > global A2 A1 A0 B0 B1 B2 B3 K w > xdot2(1)=x(2); > xdot2(2)=-A1/A2*x(2)-A0/A2*x(1)+K/A2*(B0+B1*t+B2*t^2+B3*sin(w*t)); > endfunction > > function xdot1=f1(x,t) > global A2 A1 A0 B0 B1 B2 B3 K w > xdot1(1)=-A0/A1*x(1)+K/A1*(B0+B1*t+B2*t^2+B3*sin(w*t)); > endfunction > > > if A2 == 0 > taut = 10*A1/A0; > x = lsode("f1", [0], (t = linspace (0, taut, 200)')); > y = x; > else > taut = 10*sqrt(A2); > x = lsode("f2", [0; 0], (t = linspace (0, taut, 200)')); > y = x(:,1); > end > > > set title "Dynamic Response" > set xlabel "Time" > set ylabel "Output" > set border > set nogrid > set nokey > plot(t,y) > > > > > Also, when just using GNUPLOT, I can use the size property to scale the > image. But in OCTAVE, size has another meaning. Is there some way to > scale the output? > > Any help would be greatly appreciated. > > Jarrett Campbell > [hidden email] > > |
John> You could also make the process a little easier by using gnuplot 3.6 John> which lets you have a gif terminal. i.e. John> John> gset terminal gif John> John> and avoids the pbm to gif conversion. To size the gif try something John> like: John> John> gset terminal gif size 640,480 This is not only a function of having gnuplot 3.6 (ie a 3.6 beta), but also of having a gnuplot version with gif support. Due to the legal baggage around gif and LZW compression, such versions can not be distributed. All it takes, however, is to get the 'gd' library sources from www.boutell.com, compile it and then to compile gnuplot locally. It even autodetects libgd if the latter is installed in one of the usual places. -- [hidden email] According to the latest official figures, http://rosebud.ml.org/~edd 43% of all statistics are totally worthless. |
Free forum by Nabble | Edit this page |