- Joined
- Dec 28, 2009
- Messages
- 3
- Reaction score
- 0
- Points
- 1
Hey folks, I'm a php dev who has fumbled in here and needs a little assistance.
My issue is pretty simple, I need to track the user, time logged on and time logged off on a mac.
My basic script looks like this
logon:
logoff
This works great for output like this:
user
time in
time out
user
time in
time out
But I'd really like it in this format:
user, time in, time out
user, time in, time out
I started goofing around and came up with this (untested):
for my login, which should get me halfway, but even if it works, I'm still stuck with my logout script starting on a new line:
user, time in,
time out
user, time in,
time out
Can someone point me in the right direction here?
> will write over the existing data
>> will append, but it does so with a carriage return
My issue is pretty simple, I need to track the user, time logged on and time logged off on a mac.
My basic script looks like this
logon:
Code:
do shell script "whoami >> $MacHD/LogApplicationUse/OpenDoc.txt"
do shell script "date >> $MacHD/LogApplicationUse/OpenDoc.txt"
logoff
Code:
#!/bin/bash
osascript -e 'do shell script "date >> $MacHD/LogApplicationUse/OpenDoc.txt"'
osascript -e 'do shell script "var=out; echo $var >> $MacHD/LogApplicationUse/OpenDoc.txt"'
This works great for output like this:
user
time in
time out
user
time in
time out
But I'd really like it in this format:
user, time in, time out
user, time in, time out
I started goofing around and came up with this (untested):
Code:
set user to do shell script "whoami"
set log_in to do shell script "date"
set line to user & ", " & log_in ", "
do shell script "line >> $MacHD/LogApplicationUse/OpenDoc.txt"
for my login, which should get me halfway, but even if it works, I'm still stuck with my logout script starting on a new line:
user, time in,
time out
user, time in,
time out
Can someone point me in the right direction here?
> will write over the existing data
>> will append, but it does so with a carriage return