Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How many seconds since I logged in



> set onSinceLine to paragraph 3 of (get do shell script "finger " & the_user)

Thanks, finger seems to yield more consistent results that what I was using:

paragraph 1 of (do shell script "/usr/bin/who | grep" & space & the_user)

For some reason, OMM, that wouldn't let me get login time if I logged in as
root until I opened the Terminal as root.

Anyway, this seems fairly reliable if I can settle for rounding to the
minute. I'll still look for something a little simpler that can yield
seconds. The uptime shell command apparently yields startup time and not
login time.

-----
set _who to (do shell script "id -un")

set _what to paragraph 3 of (get do shell script "finger " & _who)
set _when to (do shell script "date")

set _logintime_in_hrs to ((word 6 of _what) as integer)
set _logintime_in_mins to ((word 7 of _what) as integer)

set total_mins to ((_logintime_in_hrs * 60) + _logintime_in_mins)
set total_secs to (total_mins * 60)

set time_now_hrs to ((word 4 of _when) as integer)
set time_now_mins to ((word 5 of _when) as integer)

set current_mins to ((time_now_hrs * 60) + time_now_mins)
set current_secs to (current_mins * 60)

set up_seconds to (current_secs - total_secs)

display dialog "You logged in" & space & up_seconds & space & "seconds ago.
That's" & space & ((up_seconds / 60) as integer) & space & "minutes."
-----


Laine


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: How many seconds since I logged in (From: "Gary (Lists)" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.