1

我们正在尝试使用下面提到的终端命令通过 Applescript 安装应用程序。首先它将挂载 dmg 文件,然后将应用程序安装到 App 文件夹。将应用程序安装到应用程序文件夹时,它要求输入密码,如何使用 Applescript 处理此密码?

hdiutil mount /Users/rajasekaranr/Downloads/install_flash_player_osx.dmg"
sudo cp -R "/Volumes/Flash Player 2/Install Adobe Flash Player.app" /Applications 

使用苹果脚本执行上述命令时出错

error "sudo: no tty present and no askpass program specified" number 1
4

1 回答 1

1

尝试:

property usr : "username"
property pswd : "password"

set fromPath to quoted form of "/Volumes/Flash Player 2/Install Adobe Flash Player.app"
set toPath to quoted form of "/Applications"
do shell script "cp -R " & fromPath & space & toPath user name usr password pswd with administrator privileges
于 2012-09-07T10:54:37.443 回答