Flash icon in menu bar on remote mac when PHP script is run

Hey there

I want to be able to alert individual client’s when a task has changed on our intranet, without them having a browser open.

My thinking is that a PHP script makes the decision to either start or stop an applescript on the client mac. The PHP bit is real easy for me, but not the Applescript.

  1. Can Applescript create an icon in the menu bar and flash it?
  2. Can I remotely activate the script on an individual machine over a TCP/IP network?
  3. Can an Applescript run indefinitly until it is told to stop?

The client’s are MacOS 9.2.2. The server is an OSX 10.2.6 Mac running PHP 4.3. The network has manual IP addresses… so each machine always has the same IP address.

Any ideas, pointers etc will be gratefully received…

  1. Not that I know of.

  2. Yes, if the client is set up to allow it.

  3. Yes.

-- Save as a stay-open application

on idle
	-- do stuff
	return x -- do it every x seconds
end idle

– Rob

The way to do this (I’ve got it working on my Mac) it that you code PHP to create a text file in a folder based on the results of some web action. You also have a stay open AppleScript with an idle routine (like the one above) constantly looking for the new file. The AppleScript could read properties from the contents or the title of the new text document and delete it when it’s finished.

The PHP Code:

The stay-open AppleScript:

Hope this helps,
Jon

To pass values back to PHP from AppleScript, just do the opposite, have the AppleScript write the values to a text file and have PHP look for that file (set a loop checking for the returned file exiting when it’s there) then read, parse, and delete the file.

Jon

I’ll work my way through this over the next few days and see what I can get running…

Cheers Robsta

So I got pulled off this project and stuck on another… but back into it now.

Thanks Jonn8

I’ve taken your workings and added a bit to both the PHP and the Applescript.

Essentially I write a file from PHP that contains the user_name, password, ip_address, and a short message. (The users ip_address gets updated everytime they log in… so if they swap machines or the DHCP server does a client reset it doesn’t matter).

Then I’m just watching for a new file and then reading it in Applescript and setting the variables from the file.

And it works brilliantly for both OS 9 and OS X clients (although the applescript only runs reliably on our OSX server).

Plus users don’t even need to have their browser open… as long as they’ve logged in on the machine they’re sitting at they’ll get the new task message.

Many thanks to everyone and if you’d like the code please feel free to contact me.

Cheers[/b]