我只想編寫一個shell腳本,用於在運行我的命令時自動提供用戶名和密碼提示, 我試過這個,但沒有奏效。請幫助我解決任何問題。如何編寫自動交互式shell腳本?
#!/bin/bash
#!/usr/bin/expect
ls -ltr
spawn sudo git pull
expect "[sudo] password for sandeep:"
send "sandeep123\n"
expect "Username :"
send "sandeep\n"
expect "Password :"
send "sandeep121\n"
我得到以下輸出:
[email protected]:~$ ./checkout.sh
total 64
./checkout.sh: line 8: spawn: command not found
couldn't read file "Username:": no such file or directory
./checkout.sh: line 16: send: command not found
couldn't read file "Password:": no such file or directory
./checkout.sh: line 20: send: command not found