
我已經搜索了所有 SuperUser,但無法找到解決方案。這是一個用於 ssh 的腳本expect
。我正在使用 ubuntu 並且我已經安裝了 Expect 使用aptitude install expect
.
#!/usr/bin/expect -f
spawn ssh user@server
expect "Password:"
send "mypassword\r"
interact
當我運行此腳本檔案 sh script.sh 時,我收到此錯誤,
test.sh: 3: spawn: not found
couldn't read file "Password:": no such file or directory
test.sh: 5: send: not found
test.sh: 6: interact: not found
我已經嘗試過這篇文章,但不起作用, Ubuntu 10.04 使用 ssh 無需輸入密碼
謝謝,
答案1
您需要使您的文件可執行:
chmod +x script.sh
並像這樣運行它:
./script.sh