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

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

原文地址:https://www.cnblogs.com/rspb/p/5570750.html