|
Posted by Owen Rees on 05/22/06 01:56
On Sun, 21 May 2006 15:42:04 +0100, "Dave (from the UK)"
<see-my-signature@southminster-branch-line.org.uk> wrote in
<44707c3d@212.67.96.135>:
>Thanks. I have never used my own functions in php, so I'll take a look
>at that.
The other thing to think about is how popen executes the commands. Given
the example, it looks as if it is running a shell and passing your
command string to it. The shell will be doing its own interpreting of
the quote characters and the '$' that it finds in the string.
I suspect that you would do better to create the whole of the input to
Mathematica as a string first, then make that string the parameter to
echo, putting it in single quotes:
... popen("echo '$string' | tee ...", "r") ...
You need to do more if the string contains single quotes, but according
to a page I found on the web, PHP has a function for escaping shell args
that may do what you need (I have never used it).
While browsing round the PHP manual on the web I came across the
proc_open function - it looks as if it would let you call Mathematica
directly, writing to its input and reading from its output so avoiding
all the shell quoting and escaping issues.
--
Owen Rees
[one of] my preferred email address[es] and more stuff can be
found at <http://www.users.waitrose.com/~owenrees/index.html>
Navigation:
[Reply to this message]
|