我正在开发一个简单的苹果脚本来帮助进行日常的ssh连接
这是一个例子
tell application "Terminal"
set ServerName to "IP"
set ServerUserName to "user"
set ServerPassword to "password"
end tell
现在,我有疑问。
我如何做ssh username@servername
并发送密码?
它是这样的?
do shell script "ssh " & ServerUserName & " @ " & ServerAddress
dealy 5
keystroke ServerPassword
由于
答案 0 :(得分:0)
虽然你不应该使用@Jakuje所提到的硬编码密码,但你可以使用这种方法:
tell application "Terminal"
set ServerAddress to "IP"
set ServerUserName to "user"
set ServerPassword to "pw"
end tell
tell application "Terminal"
set currentTab to do script ("ssh " & ServerUserName & "@" & ServerAddress & ";")
delay 5
do script (ServerPassword) in currentTab
end tell
这对你有帮助吗?