A、安装SSHLibrary:   pip2 install robotframework-sshlibrary   (导入SSHLibrary)

B、远程连接linux服务器

1.#连接linux服务器方式一
open connection           192.168.99.xxx       port=22 #连接服务器
login                              root                         xxxxxxx

2.#连接linux服务器方式二(Open Connection后带alias参数,alias的值为服务器别名)

open connection           192.168.99.xxx       alias=server_xxx     port=8026 #连接服务器
login                              root                         xxxxxxx

 

十四、RF中SSHLibrary库介绍

 

C、执行远程linux命令

write               ll

write               cd /data/html

十四、RF中SSHLibrary库介绍

 

D、读取服务器内容

${text}                 read                          delay=0.8s
log                        ${text}

十四、RF中SSHLibrary库介绍

 

 

E、截取内容

1.#截取内容(按照字符串截取,下标从0开始)

${text_value1}                      get substring                   ${text}                      0
log                                          ${text_value1}
${text_value2}                      get substring                   ${text}                      1                  10
log                                          ${text_value2}

十四、RF中SSHLibrary库介绍

2.#截取内容(按照行截取,下标从0开始)

 ${text_line}                                   get line                       ${text}                          2

  log                                                 ${text_line}

十四、RF中SSHLibrary库介绍

 

 

F、拉取文件

get file                                 /data/logs/netsale/netsaleapi-2018-07-01.log                               E:/robot/logs.txt                            #将服务器的文件拷贝到本地目录

十四、RF中SSHLibrary库介绍

 

G、切换服务器

switch connection      server_137

十四、RF中SSHLibrary库介绍

 

相关文章:

  • 2021-03-29
  • 2021-09-17
  • 2021-07-07
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-01-19
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2021-10-12
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案