在ssh连接AppleScript的确认密码须藤 [英] Applescript confirm sudo password in ssh connection
本文介绍了在ssh连接AppleScript的确认密码须藤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm打开与AppleScript的一个ssh连接到一个Ubuntu框。我如何通过提供易于问sudoer密码:
告诉应用程序终端
集currentTab做剧本(SSH -p&放大器; pnumber&放大器;&放大器;用户放大器;@localhost;)
延迟2
做脚本(sudo易于得到更新)的currentTab - 开始在这里提供了sudo的密码
- 此结束在击键无法读取
按键密码
击键回
- 为此提供密码 在currentTab;做剧本(退出)
告诉结束
解决方案
尝试
设置resultText(做shell脚本apt-get的更新以管理员权限)
在误差e数n
告诉应用程序(路径最前面的应用程序为文本)
显示警报出事了:&放大器; E&安培; NR:&放大器; ñ
告诉结束
错误号-128
年底试
告诉应用程序(路径最前面的应用程序为文本)
显示警报resultText
告诉结束
在做shell脚本
您得的完整路径添加到apt-get的。如果你坚持在终端运行它,那么你就必须写一个expect脚本。
I´m opening a ssh connection to an Ubuntu Box with applescript. How can I provide the sudoer password asked by apt:
tell application "Terminal"
set currentTab to do script ("ssh -p" & pnumber & " " & user & "@localhost;")
delay 2
do script ("sudo apt-get update") in currentTab
-- start provide here password for sudo
-- this ends in keystroke cannot be read
keystroke "password"
keystroke return
-- end provide password
do script ("exit;") in currentTab
end tell
解决方案
try
set resultText to (do shell script "apt-get update" with administrator privileges)
on error e number n
tell application (path to frontmost application as text )
display alert "Something went wrong: " & e & " nr: " & n
end tell
error number -128
end try
tell application (path to frontmost application as text)
display alert resultText
end tell
You'll have to add the full path to apt-get in the do shell script. If you insist of running it in the terminal, then you'll have to write an expect script.
这篇关于在ssh连接AppleScript的确认密码须藤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文