robotframework封装ssh关键字用于远程控制和文件传输

来源:互联网 发布:java用数组输出各类 编辑:程序博客网 时间:2024/06/05 19:13

robotframework封装ssh关键字用于远程控制和文件传输

*** Settings  ***Library           SSHLibraryLibrary           String *** Variables ****** Keywords  ***OpenConnectionAndLogin    [Documentation]        ssh remote server    [Arguments]            ${ip}  ${user}  ${password}  ${alias}    Open Connection  ${ip}  alias=${alias}    Login  ${user}  ${password}SwithConnectionAndLog    [Documentation]        swith connection     [Arguments]            ${machine}    Switch Connection  ${${machine}_alias}    ${myc}  Get Connection  ${${machine}_alias}    log  ${myc.host}SshExecuteCmd    [Documentation]        ssh execute cmd, check return, 可指定机器    [Arguments]            ${machine}  ${cmd}    SwithConnectionAndLog  ${machine}    ${stdout}  ${rc} =  SSHLibrary.Execute Command  ${cmd}  return_rc=${true}    Return From Keyword  ${stdout}  ${rc}SshPutFile    [Documentation]        ssh执行命令, 判断返回码, 可指定机器    [Arguments]            ${machine}    ${src}  ${dest}    SwithConnectionAndLog  ${machine}    SSHLibrary.Put File    ${src}  ${dest}