Analog Log analyzer

Ok, I am 80% of the way there with this one. My web host places weekly logs onto my server every week. I have set up a script to check if the logs are there using Transmit, if they are then they are downloaded into a folder with the other logs. I then run a config file through Analog that uses the logs. So far so good.

Trouble is I have 3 config files I want to run, each takes around 45mins-1hour. I can’t run more than one at a time. How can I use Applescript to find out if Analog is still running from the previous run? The only AS command it supports is doScript where you can enter your own script such as Perl, or UNIX scripts or something.

At the moment I am running 3 scripts, 1 to get the logs and start the first config file and two others for the remaing files. I want to be able to just run the one script and get it to do it all.

Does Analog quit when it has finished a script? If so, then (illustrated with Safari, don’t know what the Analog process is called):


tell application "System Events" to exists process "safari"
set SafariRunning to result

If it doesn’t quit, consider a shell script using ‘top’ to see what it’s doing.

If it’s creating a file whose size changes, consider this:


to fileChanged(myFile)
	-- initialize the loop
	set Size_1 to size of (info for myFile) -- get initial size
	delay 3 --wait 3 seconds, or whatever
	set Size_2 to size of (info for myFile) -- get a newer size, perhaps bigger
	-- repeat until sizes match
	repeat while Size_2 ≠ Size_1 -- if they don't equal, loop until they do
		set Size_1 to Size_2 -- new base size
		delay 3 --wait three seconds, or whatever
		set Size_2 to size of (info for myFolder) -- get a newer size
	end repeat -- once the sizes match, the download is done
end fileChanged

If it closes the file it’s preparing when it’s done, consider a do shell script using lsof (list open files) and wait for it to close - something like this:


--set source_folder to (alias "TheVolume:ThePath:TheFile:")
set var to false
repeat until var = true
	try
		set the_files to (do shell script "lsof -F n +d " & (quoted form of POSIX path of source_folder))
	on error the_error
		if the_error = "The command exited with a non-zero status." then
			set var to true
			display dialog "The Document is closed"
		else
			set the_files to the_error
		end if
	end try
	delay 1
end repeat

or this:


try
	open for access file x -- if this succeeds, the file is not busy.
	close access result
	exit repeat
on error -- file is busy
	delay 3 -- times it out in 1 minute
end try

or this:


tell application "Finder"
	activate
	repeat while not (exists file (PathToFile & FileName))
		delay 2
	end repeat
end tell

Great, you’re a legend Adam Bell, I’ll let you know how I get on :wink: