-1
當談到Expect時,我是一個新手,我想我會先試着在我的本地機器上嘗試一下,讓自己的腳溼潤。爲Linux「adduser」命令創建一個Expect腳本
爲此,我想我會嘗試運行Expect反對「adduser」命令。
我無法讓它正常工作,好像一切正常運行,我能夠到達最後一個提示,並且它確實退出,但用戶仍然未創建。
我在做什麼錯?
#/usr/bin/expect -f
spawn adduser testuser
expect "Enter new UNIX password"
send "testpassword\r"
expect "Retype new UNIX password"
send "testpassword\r"
expect " Full Name []: "
send "\r"
expect " Room Number []: "
send "\r"
expect " Work Phone []: "
send "\r"
expect " Home Phone []: "
send "\r"
expect " Other []: "
send "\r"
expect "Is the information correct? \[Y/n\] "
send "\r"
最後加上'expect eof'。 – Dinesh
用'expect -d scriptname'運行腳本並仔細閱讀調試輸出:所有模式匹配嗎? –