Jump to content
Sign in to follow this  
axilant

Comparing file sizes

Recommended Posts

axilant

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?

Share this post


Link to post
Share on other sites
monoceres

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


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

Share this post


Link to post
Share on other sites
axilant

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

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×