通过命令行登录OSX

时间:2012-09-03 11:41:58

标签: macos bash authentication unix

我希望能够通过命令行使用login window进行身份验证。我不知道这是否可行,但如果是的话,我真的很想知道它是如何完成的。

我已经解决了这个过程被称为“loginwindow”,但我无法弄清楚如何传递任何参数。

谢谢。

2 个答案:

答案 0 :(得分:0)

这样的事情:

#!bin/sh
cat >/tmp/Login_Automatically.sh <<-"EOF"
if [[ "$(who | grep console)" == "" ]]; then # Runs ONLY if no one is logged in
osascript <<EOT
set username_ to "username"
set password_ to "password"
tell application "System Events"

(通过http://hints.macworld.com/article.php?story=2010021119293586

另外,如果您想要绕过登录,是不是可以在系统首选项中一起禁用身份验证?

或者如果你想杀死它,请阅读: Kill "loginwindow" process using command line in Mac OS X

答案 1 :(得分:0)

解决方案在this article的评论中。

复制并粘贴到命令行/ ARD:

osascript -e 'tell application "System Events" to keystroke "usernamegoeshere"'; \
osascript -e 'tell application "System Events" to keystroke tab'; \
osascript -e 'tell application "System Events" to keystroke "passwordgoeshere"'; \
osascript -e 'tell application "System Events" to keystroke return'

感谢Sam Mirrado提供该文章的链接。

Source。 engelby于2010年2月16日02:09:32发表评论。