1.要执行shell命令需要使用Robot Framework的SSHLibrary,该库用来在远程主机执行shell命令,当ip使用127.0.0.1的时候,就是在本地执行
pip install robotframework-sshlibrary
2.执行shell命令
1).建立一个ssh链接:open connection
2).执行shell命令: execute command
3).关闭ssh链接:close connection
3.获取execute command 返回值

4.eg:
Test case

Run Result

备注:
execute command 会根据参数 return_stdout, return_stderr, return_rc的设置决定返回值的内容(true:返回对应值,false:不返回对应的值)
return_stdout默认值是true,所以不设置时,默认只返回return_stdout
return_rc返回的是执行结果,0表示执行成功
本文介绍了如何使用Robot Framework的SSHLibrary在本地和远程主机上执行shell命令,包括建立SSH连接、执行命令并获取返回值,重点讲解了`executecommand`函数的参数设置和返回值控制。

898

被折叠的 条评论
为什么被折叠?



