The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Automatic Logout (http://hintsforums.macworld.com/showthread.php?t=112)

mark hunte 01-25-2008 02:31 AM

Thanks I will test on Tiger.
Can you post the error you where getting for #78 and #77

Tuxford 01-25-2008 01:46 PM

For 77 within the script editor: Stuck on 'value', System events error msg “NsreceiverEvaluationScriptError: 4”. From the line “get value of checkbox "c" of window....” Where did “c” come from. I cut and paste. How do I get the right character for CapsLock in there?

For 78, I did some editing and got it to work. Don't know why, except probably just bad path argument? Now just need to fold this code in together with the idle time code from 68. Plugging it into the script editor doesn't work. I just don't know these rules.

mark hunte 01-25-2008 05:16 PM

Hi, I have not been able to test this today, but I should have mentioned, paste the "⇪" into textedit and the copy it from there and paste it into the script. This is only needed for tiger.


Is this what you are after
Code:

#!/bin/bash
idl=$"`ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'`"
idletime="30"
if [ $idl -gt $idletime ]; then
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502
/usr/bin/osascript <<EOT
delay 5
        set password_ to "password"
tell application "System Events"
        delay 1
        tell process "SecurityAgent" to set value of text field 1 of group 1 of window 1 to password_
        click button "Log In" of window 1 of application process "SecurityAgent"
end tell
EOT
fi


Tuxford 01-25-2008 05:47 PM

Pasting from Textedit into the Script Editor doesn't work, since it changes it back to “c” upon compilation. Need another idea here.

Got #83 to work! Thanks.

Tuxford 01-25-2008 08:15 PM

New Challenge
 
If you are up to it!

Need also to automatically start my private user upon startup, since it runs some scheduled backups. Is there a way to start up user 501 in the background, rather than logging in? If not, is there a way to make user 501 immediately switch back to 502 upon this special startup condition only?

cwtnospam 01-26-2008 05:23 PM

Easy! Auto boot into user 501 and set a copy of the script to run in it using Lingo, but set the idletime to be small, the switchToUserID to be 502, and call the script after 3 or 4 minutes.

mark hunte 01-27-2008 07:14 AM

Quote:

Originally Posted by Tuxford (Post 445633)
Pasting from Textedit into the Script Editor doesn't work, since it changes it back to “c” upon compilation. Need another idea here.

I thought That had worked when I tried it, but obviously I must have dreamt it?

It looks like there is a bug in 10.4's Applescript, which see's the unicode text for Caps as a "c"


Any way those scripts that use the Caps Lock detection will Not work in 10.4
The 10.4 "KeyboardViewerServer" does not have a value for the Caps Lock to be returned

Tuxford 01-29-2008 07:36 PM

Bad news on Tiger. Thanks.

Can't seem to get any 'My Agent' to run right now? Even created a new one with the assistant to Keep an Application Running, but it does work either. What could be wrong? Logged out and back in. Dead. Why isn't Lingon reliable? How to check status?

cwtnospam 01-29-2008 07:51 PM

Lingon is very reliable. If it isn't working, there must be an error in your script. Post that, along with the plist that Lingon creates.

Tuxford 01-29-2008 07:58 PM

My server machine finally just crashed. Restarted and agents seems to be running now. Think this error condition persisted over the weekend without notification. Not good. Now need an alert when the Agents are down! Any ideas?

cwtnospam 01-29-2008 08:03 PM

Well, for that you'd need an agent, which wouldn't run if the agents were down. Unless you want it to continuously notify you that it is running, I don't think you can do that.

Tuxford 01-29-2008 08:37 PM

Well, it seems that when I restarted the server, all was running. But then I logged out of the admin user, and immediately logged back in. Since then, no agents seem to be running? Repeating the login does not help...

Should I remove Growl? I installed it per a suggestion above. I removed it.

Finally, wonder if these switch agents should be My Agents or Users Agents? Found that a KeepUp agent runs under Users Agents, but will not run under My Agents.

Confusing: Where are the preferences located for an application launched under Users Agents? Certainly is not in the My Agents users home preferences folder.

Now restarted this server which comes up as the standard user, and switched users to the admin user (a login). My Agent set to run OnLoad, ran, and brought up the short-idle switch dialogue, and switched users. I switched back and repeated. It again attempted to switch back, but I hit the cancel button and then logged out to the blue screen. Logged back in as the admin user, and now the OnLoad switch agents are not running???? Ugh! (Checked idle agents. They are not running either.) Brought up Lingon, and that agent is no longer loaded. So loaded it and logged out. Logged back in and same problem in Lingon. So I conclude that I must never log out after a restart and login as admin. What am I missing? Logging out disables the 'My Agents' until restart.

Tuxford 08-08-2008 07:48 PM

New System Error?
 
Quote:

Originally Posted by mark hunte (Post 445250)
Although I am really Happy to have found a way to detect CAPS LOCK.

I just had another go at entering the password via set value.
I found the combination that got it to work :)
So now even if the CAPS LOCK is on the script should work.

Code:

set password_ to "password"
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502"
tell application "System Events"
        delay 1
        tell process "SecurityAgent" to set value of text field 1 of group 1 of window 1 to password_
        click button "Log In" of window 1 of application process "SecurityAgent"
end tell


I am now getting an applescript error running this script under Tiger 4.11. When I run this I get a System Events error message “NSReceiverEvaluationScriptError: 4”. I need this script again, but am now stuck. It worked before, as I had it saved and was using a saved app version of it. Thanks in advance. See post #78.

cwtnospam 08-08-2008 09:17 PM

Quote:

Originally Posted by Tuxford (Post 487305)
I am now getting an applescript error running this script under Tiger 4.11. When I run this I get a System Events error message “NSReceiverEvaluationScriptError: 4”. I need this script again, but am now stuck. It worked before, as I had it saved and was using a saved app version of it. Thanks in advance. See post #78.

I just tried it by copy/pasting exactly as you posted it on my machine (10.4.11) and it worked fine. It failed on the password, but that's to be expected. ;)

Do you have a user with ID 502?
You can run this Applescript to find out:
Code:

set x to do shell script "nidump passwd . | grep 'Users'"
display dialog x


Tuxford 08-13-2008 01:49 PM

Quote:

Originally Posted by cwtnospam (Post 487310)
I just tried it by copy/pasting exactly as you posted it on my machine (10.4.11) and it worked fine. It failed on the password, but that's to be expected. ;)

Do you have a user with ID 502?
You can run this Applescript to find out:
Code:

set x to do shell script "nidump passwd . | grep 'Users'"
display dialog x


That hint was enough. Used Sharepoints to change the user ID to 502. Got it to work with and old bin bash script I used before, with Lingon calling it on 'idle'. However, need another call on 'login', which I can't seem to get Lingon to load.

On Idle call is periodically every several minutes. However, my mail server must start up initially to a protected admin user in order to launch a backup program, and then immediately switch to a standard user for security. I would like Lingon to therefore call this same bash script immediately upon login. Can't figure why 'Run at Load' checkbox doesn't allow it to work. Reminder: using Tiger.

cwtnospam 08-13-2008 03:12 PM

Quote:

Originally Posted by Tuxford (Post 488163)
However, need another call on 'login', which I can't seem to get Lingon to load.

What are you trying to call at login?

Tuxford 08-13-2008 03:18 PM

Quote:

Originally Posted by cwtnospam (Post 488182)
What are you trying to call at login?

The very same script (post #93) as the idle handler calls. I have added a few extra seconds delay in that script though. When I restart the machine, it logs into the admin user, and after the idle time, switches user. However, I am trying to get it to switch almost immediately with an additional Lingon Agent that 'runs at load'.

cwtnospam 08-13-2008 05:08 PM

I think you need the one from post#83, but that's a shell script, not an Applescript.

Tuxford 08-13-2008 05:13 PM

Quote:

Originally Posted by cwtnospam (Post 488198)
I think you need the one from post#83, but that's a shell script, not an Applescript.

I am sorry. I got confused. It is the one from #83 that I am calling using Lingon.

cwtnospam 08-13-2008 06:32 PM

The way it's written, the system would have to have been idle for more than 30 seconds when the script is first called. That's unlikely to happen right at startup. I suggest you save the script below as a different script and have Lingon call it at startup. You'll have 6 seconds after the login screen pops up to cancel the switch if you need to stay in the account.

Code:

#!/bin/bash
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID 502
/usr/bin/osascript <<EOT
delay 5
        set password_ to "password"
tell application "System Events"
        delay 1
        tell process "SecurityAgent" to set value of text field 1 of group 1 of window 1 to password_
        click button "Log In" of window 1 of application process "SecurityAgent"
end tell
EOT



All times are GMT -5. The time now is 05:42 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.