Re: shell_exec - asynchronous would be cool!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2009-02-19 at 11:15 +1300, German Geek wrote:
> Yes, believe it or not, when i was writing this, i thought about a db soln
> as well. Just hadnt done it that way back then.
> 
> I guess with Linux one could do something like:
> 
> shell_exec('{longexecutingprogram -with -params; mysql -uuser -ppass
> database query; } &');
> 
> Surely it should be possible in windows as well somehow. Does anyone know
> how (easily)? I mean i could write a win32 executable that could do it but
> that might be overkill.
> 
> But still you have to continuously check the database if the value is the
> expected which seems kind of unelegant.
> 
> Or, you could call a php script at the end like so:
> shell_exec('{longexecutingprogram -with -params; php myscript.php with
> params; } &');
> 
> In myscript.php you could have something like:
> 
> <?php
> // send request back to user whos ip and headers would have to be saved and
> sent.
> 
> ?>
> 
> Would this work? Maybe one could write a library for that directly in php...
> 
> So you could actually have a exec_async function without having to write a
> php module or something like that. I would be interested in writing a php
> module at some point anyway though. I know c(++), so it should be doable.
> 
> Is it possible to retrieve the session variables of a user in php cli?
> 
> Regards,
> Tim
> 
> Tim-Hinnerk Heuer
> 
> http://www.ihostnz.com
> George Burns  - "I would go out with women my age, but there are no women my
> age."
> 
> 2009/2/19 Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
> 
> > On Thu, 2009-02-19 at 10:30 +1300, German Geek wrote:
> > > Hi all,
> > >
> > > A while ago, i had a problem with shell_exec:
> > >
> > > I was writing some code to execute imagemagick to convert a bunch of
> > images.
> > > This could take ages to execute and the page therefore ages to load. The
> > > solution was to get a linux box and append a & at the end to do it in the
> > > background or make a ajax call to a page that does it in batches. The
> > > problem was really that i had to write a file that is then checked
> > against
> > > to know when it was finished... Not very pretty.
> > >
> > > Anyway, would it be possible to make a "new" shell_exec_async function in
> > > php that just starts the process, puts it to the background and calls a
> > > callback function or another script with parameters when it finishes? I
> > > guess a callback function is not really going to work because the page
> > needs
> > > to finish execution. It should be possible with PHP forking though.
> > >
> > > Anyway, just an idea.
> > >
> > > Regards,
> > > Tim
> > >
> > > Tim-Hinnerk Heuer
> > >
> > > http://www.ihostnz.com
> > > Emo Philips  - "I was the kid next door's imaginary friend."
> >
> > What about calling a shell script with the exec call, and as the last
> > instruction (or continually throughout its execution) it can update a
> > database entry. Your PHP code can then look to see if said entry either
> > exists or is in the right state. It should be faster and prettier than
> > writing a file.
> >
> >
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
I think the only way to do that would be to have a (don't know the
Windows terminology) daemon sitting on the system just continually
checking against the db/file and then it can make a call to the PHP. If
your site has a high volume of traffic, and extra DB call every now and
again won't hurt it too much. I use this for sites sometimes where I
just need something done once a day.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux