是否有用于启动服务器(.sh)脚本并在文本文件或变量中捕获响应的 Robot 关键字?

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

我有一个“.sh”服务器脚本,我想 运行 我的 VM 中的这个文件,在 运行ning 之后,我将在我的 VM 中发送一个 curl 请求,然后这个服务器将收到响应 我想在文件或变量中捕获整个响应。我已经尝试 运行 服务器成功了,但我对如何捕获响应以及如何切换回该服务器并在发送 curl 请求后捕获响应感到困惑。

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

其中 COL_VM 是有助于登录该 VM 的设备详细信息。

如果您的 VM 启用了 ssh,其中一个选项是使用 Python 的 Paramiko 界面的自定义库。它使用起来非常简单。这里有很多关于它的问题,例如

  • paramiko-ssh-python
  • python-paramiko-ssh-run-command

我在 Robot Framework 中使用它在 Linux 服务器上 运行 命令和脚本并验证它们的输出(stdout 和 stderr)。

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

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