|
Posted by Csaba Gabor on 01/19/08 13:09
On Jan 18, 12:08 am, wart...@hotmail.com wrote:
> This is a php group, most people dont know about c#. So my question, a
> php-related one, is: what strategy would you use n this case? To solve
> the problem, or at least to do something about this. I mean, you have
> a few php-scripts whose execution is dependent on an external program.
> What would you do in a case like this? When ou know that sometimes the
> execution can fail (and worst of all make, more or less, a whole web
> app to hang up), and you just want to exit, in those cases? What would
> you do, guys?
> As Jerry said, the try and catch will not work, as php will loose the
> control when the exec will be called.
Given your seemingly random, but consisent failure,
here is a possible approach (but I'd look at popen below, first):
In your php program, create a scheduled task whose only function
will be to execute your exec right away (this can either be
done by scheduling the task to run at the top of the next minute
or schtasks can explicitly cause the task to run (but it
requires a one line exec call) - you must ensure a unique
id). This way your original program is not
tied to the completion of your scheduled script.
The scheduled script (or rather, whatever is execed) could write
a file or leave some tracks for the original script to detect
that it has gotten sufficiently far if that's a requirement.
You have a few ways of going about this. On Windows, you can
use either AT or SchTasks. The latter may be worked with as a
COM object (otherwise you'll be looking at some version of exec).
---------
Also, as regards your exec, something I would investigate
before total frustration (if that point hasn't already been
reached) is a http://php.net/popen variant. By the way,
the exec family of functions (or something related to them)
was revised over the last year especially in regards to
being executed from php-win.exe so it's probably a good
idea to have a recent copy of php.
Csaba Gabor from Vienna
Navigation:
[Reply to this message]
|