Re: Link to .php page with session

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

 



On Tue, Jun 16, 2009 at 08:23, Stuart<stuttle@xxxxxxxxx> wrote:
>
> I may have interpreted your problem incorrectly, but I think your
> problem is due to the session data not being saved until the script
> has finished running, including the system call. To get around this
> you can save and close the session before calling system using the
> session_write_close [1] function. Note that after calling that you
> won't be able to make any other changes to the session data in that
> request.

    Stuart (<plug>who I saw yesterday is listed as a Twitter API
developer in the official docs, by the way ;-P </plug>) hit the nail
right on the head there, Santel.  Until the system() function receives
a return response from the spawned application, it'll hold up the rest
of the page execution.  There are, among others, two ways you could
easily handle this:

        1.) Write a wrapper shellscript, for which I'll give a simple
example below.
        2.) Use the proc_open()[1] or popen()[2] functions in PHP.

    To use a wrapper script is simple, and here's one way of doing it:

========
<?php
// yourfile.php

// Your existing code goes here, replacing the system() call with:
system("./convert.sh file.wmv");

// .... and then continue with your code.
?>
====
#!/bin/bash
# convert.sh
# Remember to chmod this to 0755 or similar, allowing it to execute.
nohup /usr/bin/ffmpeg -re -i $1 -f flv -an -sameq - >> /dev/null 2>&1 &

# End of shellscript.
========

    This requires only that you pass the name of the file to be
encoded, and then sends all of the output from ffmpeg to /dev/null
(including STDERR) and detaches the process from the shell (spawning a
poor-man's daemon ;-P).


    Ref:
        ^1: http://php.net/proc_open
        ^2: http://php.net/popen

-- 
</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

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