我只想编写一个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"
我得到以下输出:
sandeep@K2-Sandeep-08:~$ ./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