logging out of aqua in terminal


Hi. Is there a way to log out a user via terminal and take them back to the OS X login screen? I'm writing a shell script to logout a user if he has been on for more than a certain amount of time, and to disable usage during certain hours.

Yeah, hopefully it is. I haven't messed with Applescript much under OS X, I'll have to check it out. Does anyone know how to accomplish this with a cocoa or carbon app? I have just enough experience that I might be able to through that function in there :)

If you mean, build a scriptable app just to log out, first see if there's already a scriptable way to log out. You can call applescript from the command line, but I forget what the command is. There's a thread on it here somewhere.

Well, I looked at the Finder dictionary and there wasn't any reference to a logout command. I did see restart and shutdown, so I think I'm looking in the correct place.

I'll have to check out calling scripts from commandline, that'd be cool anyways.

I was thinking about putting it in a carbon or cocoa app b/c the program I'm writing utilizes a simple carbon app that I wrote to alert you when the computer is about to logout. If I could just find a shutdown method from there it would make it a lot smoother.

Still, as long as I get it done I'm happy :)

Try: sudo -u username_to_kick_off kill -9 -1

Just don't do it as root, or you'll kill your box :)

That's a bit of a hardcore way to do it... It'll work, but be prepared for noise and nastiness as programs don't get a chance to cleanly close their open files etc.
Ok, remove the -9 and a properly written program should shutdown gracefully, emphasis on the properly. You could run it without the -9, let any apps that shut down nicely shutdown, then run it again with -9 to kill any stubborn ones :)