SHELL自动运行脚本

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"

posted @ 2016-11-24 10:27  小黑·.·  阅读(1007)  评论(0编辑  收藏  举报