Results 1 to 4 of 4
  1. #1
    Simple applescript help

    Member Since
    Dec 28, 2009
    Posts
    3
    Simple applescript help
    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

  2. #2
    Simple applescript help

    Member Since
    Dec 28, 2009
    Posts
    3
    Wow, so either I'm so far out there no one is following my question, or this is much more difficult than I expected.

  3. #3
    Simple applescript help
    Slydude's Avatar
    Member Since
    Nov 15, 2009
    Location
    North Louisiana, USA
    Posts
    8,552
    Specs:
    2.8 GHz MacBook Pro 10.10.2, 8 GB mem, iPhone 6+
    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

  4. #4
    Simple applescript help

    Member Since
    Dec 28, 2009
    Posts
    3
    Thanks Sly, I took your advice and cross posted.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Simple AppleScript for mail
    By JosCiv in forum OS X - Apps and Games
    Replies: 10
    Last Post: 07-27-2013, 04:09 PM
  2. Simple Applescript
    By unh20050 in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 09-11-2011, 10:07 PM
  3. Simple question, If greater than x and less than y, how? #Applescript
    By aaon in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 06-08-2010, 01:34 AM
  4. Simple applescript
    By Adam in forum OS X - Apps and Games
    Replies: 0
    Last Post: 03-01-2007, 03:25 PM
  5. Simple AppleScript request...
    By 570thusaag in forum Running Windows (or anything else) on your Mac
    Replies: 0
    Last Post: 02-02-2006, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •