机器人在 SSH 连接中获取 Telnet.Execute 命令的输出
Robot get output of Telnet.Execute Command inside a SSH connection
我正在尝试获取 Telnet.Execute Command
我的 telnet 连接在 SSH 连接内部的输出。
如果我尝试 ${saida}= SSHLibrary.Execute Command ls
我可以获得 ls
命令的输出但是如果我尝试 ${saida}= SSHLibrary.Execute Command Telnet.Execute Command dir
我期望 dir
[on Telnet.Execute Command
] 命令被传递给 SSHLibrary.Execute Command
但它没有。
如何获得 Telnet.Execute Command
的输出?
Library SSHLibrary
Library Telnet
Suite Setup Open Connection And Log In
Suite Teardown SSHLibrary.Close All Connections
*** Variables ***
${HOST} OMITTED.70
${Other-Host} OMITTED.1
${OTHER-USERNAME} OMITTED
${OTHER-PASSWORD} OMITTED
${USERNAME} OMITTED
${PASSWORD} OMITTED
*** Test Cases ***
Acessando OLT para testes
SSHLibrary.Execute Command Telnet.Open Connection ${Other-Host}
SSHLibrary.Execute Command Telnet.Login ${OTHER-USERNAME} ${OTHER-PASSWORD} password_prompt=password
Verificando a saída do terminal
${saida}= SSHLibrary.Execute Command Telnet.Execute Command dir
BuiltIn.Log to console ${saida}
*** Keywords ***
Open Connection And Log In
SSHLibrary.Open Connection ${HOST}
SSHLibrary.Login ${USERNAME} ${PASSWORD}
来自评论:
I achieved to use telnet inside the ssh connection, but I want to use the Telnet Library
你不能那样做,原因有二。
首先,Telnet 库(几乎所有我能想到的 RF 库)都是为本地使用而设计的——当你开始你的案例时,它会在你的本地机器上实例化,并且在本地 [=30= 】 翻译。您对它(库)所做的所有调用都在本地计算机上完成。
因此 - 它不会在您通过 ssh 连接的机器上 运行。
另一个原因是 - Robot Framework 不支持作为参数传递 "the return value of another keyword";例如如果你想这样做,你必须将另一个关键字的返回值存储在一个临时变量中,并将它传递给第一个关键字。
换句话说,在这一行中:
SSHLibrary.Execute Command Telnet.Open Connection ${Other-Host}
,你实际上传递的是字符串"Telnet.Open Connection"和${Other-Host}
的值,你是而不是调用关键字Telnet.Open Connection
。
我正在尝试获取 Telnet.Execute Command
我的 telnet 连接在 SSH 连接内部的输出。
如果我尝试 ${saida}= SSHLibrary.Execute Command ls
我可以获得 ls
命令的输出但是如果我尝试 ${saida}= SSHLibrary.Execute Command Telnet.Execute Command dir
我期望 dir
[on Telnet.Execute Command
] 命令被传递给 SSHLibrary.Execute Command
但它没有。
如何获得 Telnet.Execute Command
的输出?
Library SSHLibrary
Library Telnet
Suite Setup Open Connection And Log In
Suite Teardown SSHLibrary.Close All Connections
*** Variables ***
${HOST} OMITTED.70
${Other-Host} OMITTED.1
${OTHER-USERNAME} OMITTED
${OTHER-PASSWORD} OMITTED
${USERNAME} OMITTED
${PASSWORD} OMITTED
*** Test Cases ***
Acessando OLT para testes
SSHLibrary.Execute Command Telnet.Open Connection ${Other-Host}
SSHLibrary.Execute Command Telnet.Login ${OTHER-USERNAME} ${OTHER-PASSWORD} password_prompt=password
Verificando a saída do terminal
${saida}= SSHLibrary.Execute Command Telnet.Execute Command dir
BuiltIn.Log to console ${saida}
*** Keywords ***
Open Connection And Log In
SSHLibrary.Open Connection ${HOST}
SSHLibrary.Login ${USERNAME} ${PASSWORD}
来自评论:
I achieved to use telnet inside the ssh connection, but I want to use the Telnet Library
你不能那样做,原因有二。
首先,Telnet 库(几乎所有我能想到的 RF 库)都是为本地使用而设计的——当你开始你的案例时,它会在你的本地机器上实例化,并且在本地 [=30= 】 翻译。您对它(库)所做的所有调用都在本地计算机上完成。
因此 - 它不会在您通过 ssh 连接的机器上 运行。
另一个原因是 - Robot Framework 不支持作为参数传递 "the return value of another keyword";例如如果你想这样做,你必须将另一个关键字的返回值存储在一个临时变量中,并将它传递给第一个关键字。
换句话说,在这一行中:
SSHLibrary.Execute Command Telnet.Open Connection ${Other-Host}
,你实际上传递的是字符串"Telnet.Open Connection"和${Other-Host}
的值,你是而不是调用关键字Telnet.Open Connection
。