Re: New to AppleScript, looking to login as a different user...
Re: New to AppleScript, looking to login as a different user...
- Subject: Re: New to AppleScript, looking to login as a different user...
- From: Norman Cohen <email@hidden>
- Date: Thu, 24 Aug 2006 08:00:16 -0700
I have to do something similar to activate my openVPN server
(Tunnelblick - great tool, btw), which is a login item in my user
account on the home machine. When I'm traveling or on an open
wireless link, I connect to my vpn server at home and use a web proxy
(squid) to surf securely.
What I do is login via ssh to my home machine and run one of several
bash alias commands that use osascript to suspend an account (usually
my daughter's), login to my account using the GUI, and then switch
back to the daughter's account. This works in Tiger, but don't know
if it works on earlier OS X versions. It also uses System Events
which means that you have to turn on the accessibility options for
assistive devices in Universal Access. These are the various alias
commands.
Login to daughter's account remotely from graphical login window:
alias loginDaughter='sudo osascript -e "tell application \"System
Events\"" -e "keystroke \"daughter\"" -e "delay 1.0" -e "keystroke
return" -e "delay 1.0" -e "keystroke \"password\"" -e "delay 1.0" -e
"keystroke return" -e "end tell"'
Login to my account when at the graphical login window:
alias loginMe='sudo osascript -e "tell application \"System Events\""
-e "keystroke \"myUserName\"" -e "delay 1.0" -e "keystroke return" -e
"delay 1.0" -e "keystroke \"duke01-champ\"" -e "delay 1.0" -e
"keystroke return" -e "end tell"'
Switch (suspend) from an account and go to the login window:
alias loginw='sudo /System/Library/CoreServices/Menu\ Extras/
User.menu/Contents/Resources/CGSession -suspend'
Actually logout a user when they are logged in graphically and their
session is active.
alias logoutuser='sudo osascript -e "tell application \"System Events
\"" -e "keystroke \"q\" using {command down, shift down, option
down}" -e "end tell"'
Hope this helps,
Norm
---
Norman A. Cohen
email@hidden
"Washington is the only place where sound travels faster than light."
C. V. R. Thompson
On Aug 23, 2006, at 23:09 PM, Joseph Trexler wrote:
Since this is all on the same machine, I'm not worried about
passwords being passed in clear text as it's just the two of us.
If anyone can point me in the right direction that would be great.
I was unable to find anything close to this on google, or a "Login"
event in the applescript help file online.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden