expect 切换用户后自动执行shell命令

#!/usr/bin/expect -f
set tvgwRecordChannel [lindex $argv 0]
set tvldFlag [lindex $argv 1]
spawn su
expect "Password: "
send "hello123\r"
expect "]#"
send "./cmm_tvgw_config.sh  $tvgwRecordChannel  $tvldFlag\r"
expect "]#"
send "/opt/fonsview/NE/cmm/bin/restart.sh\r"
expect eof

posted on 2016-06-08 17:23  renshaoping  阅读(1426)  评论(0编辑  收藏  举报