# How to get the response from command in Robot framework

**URL:** <https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962>\
**Category:** Robot Framework\
**Created:** [19 July 2023 12:54 UTC](https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962 "2023-07-19T12:54:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![szaman219](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@szaman219](https://forum.robotframework.org/u/szaman219)\
**Post date:** [19 July 2023 12:54 UTC](https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962/1 "2023-07-19T12:54:15Z")

</div>

Hi,  
I need to create program which log in to server run there some command and get the result because depending of result I need to do something else. I can log in to server and run command but I cannot get the output. I’ll be glad if someone could help me.  
Here is the program:

```plaintext
Run Script via SSH
    [Tags] DEV2
    Open Connection ${IP} 22
    ${output}= Login ${A_USER} ${A_PASS}
    Should Contain ${output} Last login 
    Write cd json
    ${outputs} Execute Command ctm build create_job.json
    Log To Console ${outputs}
    Close All Connections 

```

Best regards

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [19 July 2023 13:09 UTC](https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962/2 "2023-07-19T13:09:20Z")

</div>

Hi Przemyslaw,

Firstly it looks like you are missing an equals (=), not sure if this is related or not?

```python
${outputs}= Execute Command ctm build create_job.json

```

Next, Is the output from your command `ctm build create_job.json` returned to the stdout or the stderr? Does it even output any text at all or maybe just returns a return code?  
Based on the way you are calling [Execute Command](http://robotframework.org/SSHLibrary/SSHLibrary.html#Execute%20Command) you are only getting the stdout, perhaps you need to get the stderr as well?

```python
${stdout} ${stderr}= Execute Command ctm build create_job.json return_stderr=True
Log To Console ${stdout}
Log To Console ${stderr}

```

Beyond that, you could also try one of the [Read](http://robotframework.org/SSHLibrary/SSHLibrary.html#Read) keywords and see if you can use one of them to get what you are after.

Hopefully that helps,

Dave.

---

<div class="post-metadata">

**Author:** ![szaman219](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@szaman219](https://forum.robotframework.org/u/szaman219)\
**Post date:** [21 July 2023 12:32 UTC](https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962/3 "2023-07-21T12:32:51Z")

</div>

Hi Dave,  
thanks for this because now I see where is the problem but maybe someone have an idea how to resolve this? Because I do not understand how could be the problem with authorizations after successfully connected to the server.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/e/e3502665f5f909b336457cb15218421b2f93dedd.png)

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [21 July 2023 14:25 UTC](https://forum.robotframework.org/t/how-to-get-the-response-from-command-in-robot-framework/5962/4 "2023-07-21T14:25:31Z")

</div>

Hi Przemyslaw,

Well because that error is in your stderr then it’s come from your ctm executable or what ever it’s interacting with so it’s probably beyond what anyone in this forum can help you with.

- I would suggest you start by checking the contents of `create_job.json` to see if there is a username and password in there (or a place for them)?
- next I’d try manually creating a ssh session to that machine with the same user and password and running that command (`ctm build create_job.json`) in that ssh session and see if you get the same error or something else
  - if something else then you have to look at what’s different from your ssh session to the ssh session robot creates, pay close attention to the variables especially any variables related to proxy servers, you might want to start by manually connecting a ssh session to that host with that user and pass, run `printenv` and store the result, then in your test do a `${stdout} ${stderr}= Execute Command printenv return_stderr=True` and compare the results

Unfortunately I don’t think this is the best place to get help with errors from what ever `ctm build` is.

Hope that helps,

Dave.
