New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Ľ Advice and insight from world-class Apple enthusiasts Ľ Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Simple applescript help


Post Reply New Thread Subscribe

 
Thread Tools
Doc Thirst

 
Member Since: Dec 28, 2009
Posts: 3
Doc Thirst is on a distinguished road

Doc Thirst is offline
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:
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
QUOTE Thanks
Doc Thirst

 
Member Since: Dec 28, 2009
Posts: 3
Doc Thirst is on a distinguished road

Doc Thirst is offline
Wow, so either I'm so far out there no one is following my question, or this is much more difficult than I expected.
QUOTE Thanks
Slydude

 
Slydude's Avatar
 
Member Since: Nov 15, 2009
Location: North Louisiana, USA
Posts: 6,546
Slydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant future
Mac Specs: 2.8 GHz MacBook Pro 10.8,3 8 GB mem, 2.66 GHz Mac Pro - Dead, iPhone 4

Slydude is online now
You might find a bit more help with the scripting at MacScripter.

Sylvester Roque Former Contributing Editor About This Particular Macintosh

"Got Time to breathe. You got time for music." Denver Pyle as Briscoe Darling
QUOTE Thanks
Doc Thirst

 
Member Since: Dec 28, 2009
Posts: 3
Doc Thirst is on a distinguished road

Doc Thirst is offline
Thanks Sly, I took your advice and cross posted.
QUOTE Thanks

Post Reply New Thread Subscribe


« startup my application when i start pc | How can i get started with app development? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
newbie question on XCode 3.2: how to populate pop up buttons/link to applescript nickharambee OS X - Operating System 0 10-21-2009 07:10 AM
A simple JavaScript calculator mraya Web Design and Hosting 9 02-23-2009 06:16 PM
Simple applescript Adam OS X - Apps and Games 0 03-01-2007 03:25 PM
Simple AppleScript request... 570thusaag Running Windows (or anything else) on your Mac 0 02-02-2006 12:33 PM
[ANN] New comprehensive AppleScript book hanaan OS X - Development and Darwin 0 11-06-2004 07:28 PM

All times are GMT -4. The time now is 12:17 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?