Re: Wait till file contents changed
| From: | Jasper Kips | Date: | Mon, 07 Nov 2016 16:29:18 +0000 |
| Subject: | Re: Wait till file contents changed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325826@lists.php.net to get a copy of this message | ||
Create a file handle, $handle = fopen($filename, ‘r’, ), create a variable, $busy = true, then
create a loop. while busy, $contents = fread($handle, 1 ), if $contents is 1 set busy to false.
However, the elegant solution would be:
<path to php>/php <path to file to execute>
at te end of the script.
Jasper Kips
______________________________________
Telefoon: + 31 6 25 37 83 34
E-mail: jasper@planetkips.nl
> Op 7 nov. 2016, om 16:19 heeft Danny <mynixmail@gmail.com> het volgende geschreven:
>
> Hi,
>
> I am trying to figure out a way to do the following:
>
> I have a cli script that has to wait untill the contents of a file has changed
> from a "0" to a "1".
>
> If it is a "0", the script must wait, if it is changed to a "1" the script
> must
> continue. The "0" and "1" is written by a BASH script.
>
> When the bash script is run , it echo's a "0" into the file to tell php that the
> process has started and php should wait untill the process is finished which
> occurs when the BASH script echo's a "1" into the same file.
>
> Any pointers?
>
> Thank you
>
> Danny
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>