• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AS Click Counter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS Click Counter


  • Subject: Re: AS Click Counter
  • From: Jolly Roger <email@hidden>
  • Date: Fri, 07 Dec 2001 10:13:59 -0600

On 12/7/2001 6:46 AM, "Simon Topliss" <email@hidden> wrote:

> I've written quite a few scripts where I work that automate various
> processes. I've been asked to add some kind of 'click counter' to each of
> the scripts so we can record how many times a script is run. That will
> enable us to calculate time savings per script (manual versus automatic).
>
> I can't decide on the best approach for this. It would be simple to write to
> a log file on each of the client macs when each script is run, but then I
> would have to figure out a way to automatically get the logs from about 100
> macs each week.
>
> I think the best approach I have so far would be for me to set up a mac on
> our network that is able to receive an apple event over IP sent by the
> scripts when launched. This raises other questions:
>
> Is there an application out there that can receive apple events over IP that
> is suitable? Could/should I use an application like BBEdit to receive the
> calls and write to a log file?
>
> If I write my own stay open applet and install that on the server, what
> happens when it receives multiple calls at the same time?
>
> Any other ideas/suggestions would be really appreciated.

What about doing something like this:

1) Turn on File Sharing on the server.

2) Run the following "Logger" applet script on the server:

(Save the script as a stay-open application):

-- begin script
property gLogFolder : (path to (the startup disk) as text) & "Desktop
Folder:"
property gLogFileName : "Client usage log.txt"
property gLogRef : 0

-----------------------------------------------------

on LogEntry(someText)
set gLogFile to (gLogFolder as text) & gLogFileName
try
if gLogRef = 0 then set gLogRef to open for access (file gLogFile)
with write permission
on error
-- remove old log file (it may have been left open)
collate gLogFile with the trasher -- Akua Sweets
-- try to open it again
set gLogRef to open for access (file gLogFile) with write permission
end try
if gLogRef  0 then
write FormatDateTime(current date) & ": " & someText & return
starting at eof to gLogRef
close access gLogRef
set gLogRef to 0
end if
end LogEntry

-----------------------------------------------------

on FormatDateTime(theDate)
set theDate to theDate as date
set dd to text -2 thru -1 of ("0" & theDate's day)
copy theDate to tempDate
set the month of tempDate to January
set mm to text -2 thru -1 of ,
("0" & 1 + (theDate - tempDate + 1314864) div 2629728)
set yy to text -1 thru -4 of ((year of theDate) as text)
set hh to time string of theDate
return (yy & mm & dd & " " & hh as text)
end FormatDateTime
-- end script

3) Have each client script call the Logger script applet on the server each
time they run with this syntax:

tell application "Logger" of machine "server name" to LogEntry("Client
has started up")

HTH

JR


References: 
 >Re: AS Click Counter (From: Simon Topliss <email@hidden>)

  • Prev by Date: Re: Duplicate with replacing and a full trash
  • Next by Date: Re: Duplicate with replacing and a full trash
  • Previous by thread: Re: AS Click Counter
  • Next by thread: Re: AS Click Counter
  • Index(es):
    • Date
    • Thread