2016-01-21 86 views
0

我正在嘗試在期望腳本(以下代碼)內運行期望腳本。但是,我收到以下錯誤:在期望腳本中啓動期望腳本

spawn ./script.exp 
couldn't execute "./script.exp": no such file or directory 
    while executing 
"spawn "./script.exp"" 
    (file "./script.exp" line 7) 

我有雙重檢查和script.exp存在並位於/ home/user/scripts目錄中。

#!/usr/bin/expect 

spawn ssh [email protected] 
expect "$" 
send "cd /home/user/scripts\r" 
expect "$" 
spawn "./script.exp" 
expect "$" 
send "logout\r" 
+1

'spawn'在你的本地機器上啓動一個新的進程。要在遠程機器上啓動該腳本,請使用'send「./script.exp\r」' –

+0

謝謝。有用。 – synthesis

回答

0

按照上面給出的建議,使用send "./script.exp\r"
代替spawn "./script.exp",解決了這個問題。