写脚本切换用户

  1. #!/usr/bin/expect
  2. spawn /bin/su
  3. expect "Password: "
  4. send "u_password\r"
  5. expect eof
  6. exit
send:用于向进程发送字符串
expect:从进程接收字符串 比如:expect "*assword*"
spawn:启动新的进程
interact:允许用户交互
posted @ 2016-03-31 15:04  夜空释  阅读(203)  评论(0)    收藏  举报