2017-08-16 46 views
-1

試圖運行這段代碼,但「執行未設置」錯誤不斷髮生在執行命令行。機器人框架:telnet執行命令「提示未設置」

*** Settings *** 
Library Telnet 
Library Telnet ${out} 
Library Collections 
Library Collections ${y} 
Library Collections ${x} 

*** Variables *** 
${ip} 0.0.0.0 
${port} 0 

*** Test Cases *** 
telnet to server 
    Open Connection ${ip} ${port} 

verify something 
    ${out}= Execute Command ls 
    ${y}= Get From List ${out} 0 
    Should Match Regexp ${y} /^ID$/ 

Exit Test 
    Close All Connections 

我也試着刪除「圖書館遠程登錄$ {}出來」,並取代「$ {}出來= 執行命令ls」與下面的線,但收到同樣的錯誤。

Write ls 
Set Prompt ${out} 
${out}= Read Until Prompt 

是否有語法問題?或者,「提示」的用法是完全錯誤的嗎? (如果是的話,我怎麼能解決這個問題?)

(注:這是機器人框架的第一次嘗試,所以請隨時對任何其他問題發表評論!)

+0

請顯示實際的錯誤。 –

+0

你是什麼意思的實際錯誤?我在日誌文件中發現的唯一錯誤是「未設置提示符」。 –

+0

所以,你會得到一個空白的屏幕,確切地說這些詞「提示未設置」?沒有其他信息 - 沒有其他的背景? –

回答

0

一切都在Telnet文檔。我使用RED機器人編輯器,可以通過將鼠標懸停在編輯器遠程登錄進入顯示我的Telnet和Telnet KW文檔,這也可以通過命令行產生:

python -m robot.libdoc Telnet show 

有一個關於提示部分:

== Prompt == 

Often the easiest way to read the output of a command is reading all 
the output until the next prompt with `Read Until Prompt`. It also makes 
it easier, and faster, to verify did `Login` succeed. 

Prompt can be specified either as a normal string or a regular expression. 
The latter is especially useful if the prompt changes as a result of 
the executed commands. Prompt can be set to be a regular expression 
by giving ``prompt_is_regexp`` argument a true value (see `Boolean 
arguments`). 

Examples: 
| `Open Connection` | lolcathost | prompt=$    | 
| `Set Prompt`  | (> |#) | prompt_is_regexp=true | 

查看Telnet文檔以獲取更多幫助和示例。

ps。我沒有看到導入帶參數的Telnet的原因:

Library Telnet ${out} 
相關問題