【发布时间】:2018-04-20 19:32:42
【问题描述】:
在robotframework中通过ssh库执行命令
我正在使用robotframework 连接到远程服务器并在那里启动应用程序。我使用这些关键字:
Create SSH Link
Open Connection ${Ip}
Login ${Username} ${Password}
Start Service
${cmd} = "cd " + ${appAddr} + "; ./" + ${appName} + " " + ${appInputArg} + " > /tmp/" + ${appName} "-out.log 2>&1"
log to console Going to run command: ${cmd}
execute command ${cmd}
log to console \nConnected Successfully
Run App
${cmd} = "netstat -putan | grep LISTEN | grep 8898 | awk '{print $7}' | cut -d '/' -f 1"
${stdout} = execute command ${cmd}
Run Keyword If ${stdout} == ${EMPTY} log to console \nCommand ${cmd} retruned Error
Run Keyword Unless ${stdout} == ${EMPTY} Start Service
这是我的测试用例:
Test Connecting to Remote Server
Create SSH Link
Run App
然后输出:
==============================================================================
Scenarios
==============================================================================
Scenarios.Test :: First Test
==============================================================================
Test Connecting to Remote Server
Connected Successfully
| FAIL |
No keyword with name '"netstat -putan | grep LISTEN | grep 8898 | awk '{print $7}' | cut -d '/' -f 1"' found.
------------------------------------------------------------------------------
Scenarios.Test :: First Test | PASS |
0 critical tests, 0 passed, 0 failed
1 test total, 0 passed, 1 failed
==============================================================================
Scenarios | PASS |
0 critical tests, 0 passed, 0 failed
1 test total, 0 passed, 1 failed
==============================================================================
为什么不在远程服务器上执行这个命令并搜索关键字??
【问题讨论】:
标签: ssh robotframework