0

I'm trying to get the output of a Telnet.Execute Command my telnet connection is inside of a SSH connection.

If I try ${saida}= SSHLibrary.Execute Command ls I can get the output of the ls command but if I try ${saida}= SSHLibrary.Execute Command Telnet.Execute Command dir I was expecting that the output of the dir [on the Telnet.Execute Command] command was passed to the SSHLibrary.Execute Command but it is not.

How can I get the output of the 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}
vladwoguer
  • 951
  • 1
  • 14
  • 28
  • I'm not sure I understand your intent, can you elaborate what are you trying to accomplish? Do you want to give as argument of `Execute Command` the output of `Telnet.Open Connection`? Or you want to run telnet in the ssh session? – Todor Minakov May 10 '19 at 08:49
  • @TodorMinakov I achieved to use telnet inside the ssh connection, but I want to use the Telnet Library – vladwoguer May 10 '19 at 16:22
  • Yes I want to open a telnet connection and get feedback inside a SSH connection using the robot libraries for both ssh and telnet. The telnet connection works, but I do not get feedback from Execute Command – vladwoguer May 10 '19 at 16:25

1 Answers1

1

From the comments:

I achieved to use telnet inside the ssh connection, but I want to use the Telnet Library

You can't do that, for two reasons.

First, the Telnet library (as pretty much all RF libraries I can think of) is designed for local usage - when you start your cases, it is instantiated on your local machine, and in the local python interpreter. All calls you make to it (the lib), are done on the local machine.
Thus - it will not be ran on the machine on which you connected to through ssh.

The other reason is - Robot Framework does not support passing as arguments "the return value of another keyword"; e.g. if you want to do that, you have to store the returned value from that another keyword in a temp variable, and pass it to the first keyword.
In other words, in this line:

SSHLibrary.Execute Command  Telnet.Open Connection  ${Other-Host}

, you are actually passing the strings "Telnet.Open Connection" and the value of ${Other-Host}, you are not calling the keyword Telnet.Open Connection.

Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
  • Thank you @TodorMinakov. In fact the connection is achieved cause if I change the password in `SSHLibrary.Execute Command Telnet.Login ${OTHER-USERNAME} ${OTHER-PASSWORD} password_prompt=password` I get a login error. But by what you said it's a unexpected behavior. I will choose your answer. – vladwoguer May 10 '19 at 16:43