1

I am trying to execute an Octave script from PHP in the eclipse environment. The set up PHP, Apache works yet. The problem occurs related to the following call:

$cmd = "octave3.8 -qf /.../path_to_file/myscript.m file.txt";
$ex = passthru($cmd, $output);
var_dump($ex);
var_dump($output); 

inside the script myscript.m there is:

e = 5                % too see if it will be printed onto the web page
arg = argv();        
data = load(arg{1}); 

The result is : NULL int(1)

Few keynotes:

  • The same command from the terminal works fine (octave3.8 -qf /../path_to_file/myscript.m file.txt)
  • I already tried to put the PHP process to be run by a sudoer

On Ubuntu 12.04, Octave 3.8.0, Eclipse standard/SDK 2.0.1., PHP Dev Tools 3.2.0.

2

2 Answers 2

0

Your command line should be:

octave --no-gui --quiet /path/to/script.m

and the contents of the script should be:

e = 5;
disp(e);
2
  • it doesn't work either. the command -q is for quiet and no gui is the default on octave 3.8.0
    – eykiriku
    Jan 28, 2014 at 17:53
  • @eykiriku, I don't think so. At least on the Linux build, the GUI is the default. You need -q to silent the Octave welcome message. Also, please pay attention to argv(), it includes all the flags and extra arguments you pass in the command line.
    – juliohm
    Jan 28, 2014 at 20:43
0

Really you want to do this? New Octave version of does not support pipes. You may face many security problem when user type commands like file or system related octave functions. New graphics toolkit fltk will hang when you are using octave through pipe. Still you are interested search online octave on google. Hm. There is Nclab, its a cloud based.

1
  • what do you mean for pipe? This php script doesn't need ANY input from the user.The flow of my PHP script is: PHP accesses a database, retrieve the file "file.txt", passes it to octave that will do all the processing and will give the results back to the PHP script to either be saved to another file or printed to the webpage. What's the gain by using Nclab instead of a standalone installation of octave on a webserver?
    – eykiriku
    Jan 29, 2014 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.