Jump to content

Recommended Posts

Posted

My code:

$file = "data.txt";
Run("php test.php", "", @SW_HIDE);
$filesize = FileGetSize($file);
while 1
    
    if $filesize < FileGetSize($file) Then
        $filesize = FileGetSize($file)
        msgbox(0,"size changed", "it changed...")
        EndIf
sleep(500);
    WEnd
    Opt("OnExitFunc","OnAutoItExit");
    func OnAutoItExit()
        Run(@ComSpec & " /c taskkill /IM php.exe /F", "", @SW_HIDE)
    EndFunc

basically the while loop doesn't work. Is it because my php script is ran in a never ending while, and it is waiting for it to be done, or what?

I'd appreciate some help with this, and im just messing around with this out of complete boredom. Also, do I have to have the opt there since OnAutoItExit is the default?

Posted (edited)

  monoceres said:

I don't think your php file is "run" at all, try ShellExecute() instead :)

Yes it is, because i have new data in the file every 5 seconds, the while just isn't catching the new filesize. It works fine, i just need it to catch the new file size.

<?PHP
function writefile($file,$source)
    {
        $write = @fopen("$file", 'a+');
        @fwrite($write, $source);
        @fclose($write);
        return(true);
    }
    while(true)
    {
        sleep(5);
        writefile("data.txt", time() . "\n");
    }
?>

Nevermind, it was because of permissions on the file. My bad, appreciate it. Stupid me >.>

Edited by axilant
Posted

Try changing this:

if $filesize < FileGetSize($file) Then

To

if $filesize <> FileGetSize($file) Then

Broken link? PM me and I'll send you the file!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...