简体   繁体   中英

Is there any Robot keyword for starting a server(.sh) script and capture the response in a text file or a variable?

I am having a ".sh" server script i want to run this file in my VM, after running i will send a curl request in my VM then this server will receive a response i want to capture the whole response in a file or variable. I have tried to run the server it was successful but i am stuck with how to capture the response also how to switch back to this server and capture the response after sending curl request.

CLI    COL_VM    cd server_path/                        prompt=$  timeout=30
${result}      CLI    COL_VM    ./server.sh             timeout_exception=0

where COL_VM is the device details which will help to login to that VM.

If your VM has ssh enabled one of the options would be a custom library using Python's Paramiko interface. It is pretty simple to use. There were many questions about it here, eg

I use it in Robot Framework to run commands and scripts on Linux servers and verify their output (both stdout and stderr).

我没有尝试从服务器捕获响应,而是捕获了 curl 请求的响应本身。

${curl}      CLI    COL_VM    curl -X GET \http://localhost:8083/Path \ -d 'curl_request_json_which_we_are_sending'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM