Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Calling Mac OS 1337|\|355

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 09:24 - 22 Mar 2006    Post subject: Calling Mac OS 1337|\|355 Reply with quote

I need to find someway of shutting down a Mac (OS 10.4) after a certain time period. The way it needs to work, is to have the script check the last modified date of the antivirus folder. If it is less than 23 days, it ignores it and everything carries on as normal. Between 23 days and 29 days, it should display a message saying 'You have x days left' or something. On the 30th day, it should show a message 'Please return the laptop' and shutdown after a short delay. It needs to only work on a limited account, obviously not the root or admin account. My knowledge of UNIX and MacOS is utter shite to say the least, so any help on the matter is greatly appreciated.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 10:29 - 22 Mar 2006    Post subject: Reply with quote

Write a little script that checks the date of the folder, and does nothing if it's OK, or runs your shutdown/message script if it's too old.

Then add that script to cron, and set it to run every hour or something.
Could also add the script to a startup routine, so if it's too old it'll shutdown as soon as they start the laptop too.
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 12:13 - 22 Mar 2006    Post subject: Reply with quote

I would write the script, but I can't Razz

But yes, that's the idea. It needs to run once when they log in on the limited account.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 12:25 - 22 Mar 2006    Post subject: Reply with quote

fuzz wrote:
I would write the script, but I can't Razz

But yes, that's the idea. It needs to run once when they log in on the limited account.


It needs to run periodically as well as when the first log in.
What if they log in before the period ends, and then just leave it logged in and turned on? Wink

I'd need access to the system if I was going to write your script for you.
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 12:31 - 22 Mar 2006    Post subject: Reply with quote

Suzuki wrote:
It needs to run periodically as well as when the first log in.
What if they log in before the period ends, and then just leave it logged in and turned on? Wink


They wont.

I could probably write the script if I had pseudocode to work from. I can learn the commands by googling, but I have no understanding of UNIX at all (well, very, very little).
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 09:30 - 26 Mar 2006    Post subject: Reply with quote

You still struggling with this? Or have you sorted it yet?
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 20:51 - 26 Mar 2006    Post subject: Reply with quote

I've written an Applescript that checks the date of a file, then warns or shuts down the system depending on the date. The trouble I'm having now is getting the script to run when the limited user logs in. I have set it to run at login, but it requires the user to click the app opening icon on the dock to run the script. If the user doesn't click it, it times out. If I can get it to run the script automatically, all will be well. I tried using osascript, but found out it doesn't like user interaction, i.e. display dialogs.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 09:21 - 27 Mar 2006    Post subject: Reply with quote

So far I have:

Quote:
set mainfile to "Macintosh HD:Applications:test.rtf" --set path to update file
set now to current date --gets todays date

tell application "Finder"
set filedate to modification date of file mainfile --gets last modified date of file
end tell

set Age to now - filedate --compare the file date with today
set daysleft to (30 * days) - Age --calculates days left to next update
set daysleft to daysleft div days + 1 --truncates days left, so increment by one

if daysleft < 1 then
display dialog "This iBook must be returned to ICT services and will no longer function until security updates have been installed." buttons "OK" giving up after 20 with icon 0
tell application "System Events"
shut down
end tell
else if daysleft < 7 then
set msgstring to "You have" & space & daysleft & space & "days left to return this iBook for updates."
display dialog msgstring buttons "OK" with icon 2
end if


I have tried executing it from a second script that calls it, but this doesn't seem to solve the problem of the app not opening from the dock.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 10:32 - 27 Mar 2006    Post subject: Reply with quote

Ooooh Confused

I've never use Applescript, so I will be completely useless to you now.

Perl I could have handled Wink
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 11:06 - 27 Mar 2006    Post subject: Reply with quote

I think Applescript was the wrong way to go. It does the job, but I cant run it from the limited account, even if I give it rwx permissions.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

Suzuki
Roger



Joined: 03 May 2005
Karma :

PostPosted: 11:19 - 27 Mar 2006    Post subject: Reply with quote

You'd probably be best writing a shell script.

If you're struggling with what the commands are, drop me a PM or MSN me. Smile
____________________
<Simple> no I'm shaven Jon Razz
<Simple> it is a big enough hole.. I'll leave it now
Ride: 1999 Suzuki GSXR600 (yellow/black) IRC: Stats - Relationship Map
 Back to top
View user's profile Send private message Send e-mail Visit poster's website You must be logged in to rate posts

fuzz
World Chat Champion



Joined: 24 Mar 2004
Karma :

PostPosted: 08:40 - 29 Mar 2006    Post subject: Reply with quote

Sorted it Thumbs Up I kept the Applescript but changed it around a little to get it to work with a login hook.
____________________
https://www.bikepics.com/members/fuzzbcf/
Bikes: '99 NSR125R, '00 SV650S, K1 GSX-R600, '97 CB500, K3 SV1000S, '16 VFR800
 Back to top
View user's profile Send private message You must be logged in to rate posts

ali-b
Trackday Trickster



Joined: 19 May 2005
Karma :

PostPosted: 13:52 - 03 Apr 2006    Post subject: Reply with quote

You could probably use CRON to schedule checks (for login, and/or a timeframe).

There are loads of apps out there that GUI-ize the CRON scheduler.

I guess you're pretty much sorted, only just seen this so thought I'd suggest the CRON

A.
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts
Old Thread Alert!

The last post was made 19 years, 321 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.07 Sec - Server Load: 1.02 - MySQL Queries: 13 - Page Size: 81.23 Kb