in reply to ticked off with backticks

alternatively, use the OPEN function with a pipe like so
open(GNUPLOT,"gnuplot $cmd |") or die; @output = <GNUPLOT>; close GNUPLOT or die "error reading GNUPLOT";
this is my preferred way. The close function makes sure that buffers are flushed. From my experience as programmer...the complex lines in a program are usually not at fault...instead it's the simple lines that cause problems. print $cmd to stdout just to make sure it has what you think it has. regarding apache user permissions...you can replicate how it works on the webserver by su - nobody, or whatever the apache user is, and try to run the program on the command line, i.e. gnuplot $whatever_your_cmd_is

Replies are listed 'Best First'.
Re^2: ticked off with backticks
by bret.foreman (Acolyte) on Aug 19, 2004 at 16:21 UTC
    Since IPC::Run was not installed on my system, I tried the open method first. The close of GNUPLOT fails and $! is empty. I guess it's failing because I'm trying to close it with some data still buffered but why no error message?

    I also put some invalid options in the gnuplot command to be sure that it is returning an error message. But @output is empty. The message is probably still buffered in GNUPLOT. Is there a way to flush it?

    Thanks,
    Bret

      The message is probably still buffered in GNUPLOT. Is there a way to flush it?

      The call to <GNUPLOT> in list context will slurp everything the filehandle has to read, and close should flush any buffers automatically. With aquarium's code, if the buffers fail to flush, die would be called.