You are here: Re: How do I quote this in php? « All PHP « IT news, forums, messages
Re: How do I quote this in php?

Posted by Dave (from the UK) on 05/22/06 13:32

Owen Rees wrote:
> 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.

Yes, I think this is an issue. I've got something that works reasonably
well now.

http://www.althorne.org/witm/witm.php
http://www.althorne.org/witm/witm.txt

but there are a few issues, some of which I can probably solve, others I
doubt I can.

The producers of Mathematica sell a product webMathematica

http://www.wolfram.com/products/webmathematica/index.html

which I have anyway), but it is quite restrictive. It's designed to
allow a very small subset of Mathematica to be used by anyone with
access to the web. In contrast, I want the full functionality (or as
much as I can get), but have it password protected.

> 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") ...

Unfortunately Mathematica seems to use just about every character that
might cause a problem - *, $, ', ", `, /, <. >, \ etc. In fact it has a
shell escape:

Mathematica 5.2 for Sun Solaris (UltraSPARC)
Copyright 1988-2005 Wolfram Research, Inc.
-- Motif graphics initialized --

In[1]:= ! grep root /etc/passwd
root:x:0:0:Super-User:/:/sbin/sh

However, I have to be practical and some of these are very rarely used
and often there is another way of doing something.

> 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).

This gets more complicated by the minute.

> 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.

I got the feeling it was designed for bi-directional pipe use, so would
give no advantage in my case, but perhaps I am wrong.

That said, the programming interface between Mathematicas front end and
the computational engine is published.

http://documents.wolfram.com/v5/Add-onsLinks/MathLink/MathLinkIntroduction/2.13.1.html

so one can write programs to interact with it. With a bi-directional
pipe one could do a lot, but that would be a lot of work I think - far
more than I am willing to attempt.

--
Dave K MCSE.

MCSE = Minefield Consultant and Solitaire Expert.

Please note my email address changes periodically to avoid spam.
It is always of the form: month-year@domain. Hitting reply will work
for a couple of months only. Later set it manually.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация