Of course... How haven't I thought that? Pipes!
I was "googling" about PHP and Octave and I had found some simple approach at a mailing list archive. I had already used Octave with PHP but I had always used temporary files, but pipes are a much simpler approach.
From the mailing list post:
I was "googling" about PHP and Octave and I had found some simple approach at a mailing list archive. I had already used Octave with PHP but I had always used temporary files, but pipes are a much simpler approach.
From the mailing list post:
in php
start "octave -q script" with popen
create a string in php e.g. "input_data = [102 10 10 10 10 10];"
write this string to the pipe
in octave
recive the string with fread on stdin
let the eval function do the job
calculate
print the result with printf in php syntax "$result = array(12,10,9,12,)"
php
read the output from the pipe (with php fread)
use phps eval function
but using eval with octave and php is a security risk, to avid eval parse
the matrix wird scanf
this is also not the fastes way to use octave (the octave startup needs a
lot of time)
Hello! I'm really interested about this idea, but I'm not sure how to implement it. Would you write a sample PHP file?
ReplyDeleteThank you very much!
Juanlu_001,
ReplyDeleteI didn't write any prototype calling the GNU Octave this way. As soon as I have one, I will post it here at my blog.
What I already have about PHP+Octave is a old post on a pumps dimensioning system.
Check out Octave daemon, if you ever need something like this again.
ReplyDelete