SHELL自动运行脚本

时间:2021-08-23 13:04:43

pass.sh

------------------------

#!/bin/bash
echo start

/usr/bin/expect <<EOF
set timeout 10
spawn sudo su
expect "password for wadi:"
send "1\n"
expect "*#"
send "cd ~\r"
expect "*#"
send "/home/wadi/shell/passwd/shell.sh\n"
expect "*#"
send "exit\r"
interact
EOF
echo "\n"

whoami
echo end

----------------------

shell.sh

#!/bin/bash
echo "yes"