Help us understand the problem. What is going on with this article?

Robot Framework 使ってみる③

リモートホストでコマンド実行してみる(2回目)

Robot Framework 使ってみる①
やってみたいことの2番目:vyos内のファイルを取得する に挑戦する。

http://robotframework.org/SSHLibrary/SSHLibrary.html
get file : 絶対これだと思う!

とりあえず手動。

# scp vyos@172.17.0.2:/var/log/messages ./
Welcome to VyOS
vyos@172.17.0.2's password:
messages 100% 228KB 58.7MB/s 00:00
# ls -l
total 728
~snip~
-rw-r----- 1 root root 233350 Sep 9 02:46 messages
~snip~
#

Get file

test04
# cat test04.robot
*** Settings ***
Library SSHLibrary

*** Variables ***
${user} vyos
${password} vyos
${ip1} 172.17.0.2
${ip2} 172.17.0.3

*** Test Cases ***
ssh test of vyos
    vyosに接続
    vyosにログイン
    ${output} = Execute Command echo SSH to vyos is OK!
    Log To Console ${\n}${output}
    Should Be Equal ${output} SSH to vyos is OK!

get messages
    Get File /var/log/messages

*** Keywords ***
vyosに接続
    Open Connection ${ip1}
vyosにログイン
    Login ${user} ${password}
#

で、実行。

# robot test04.robot
==============================================================================
Test04
==============================================================================
ssh test of vyos ...
SSH to vyos is OK!
ssh test of vyos | PASS |
------------------------------------------------------------------------------
get messages | PASS |
------------------------------------------------------------------------------
Test04 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
==============================================================================
Output: /root/output.xml
Log: /root/log.html
Report: /root/report.html
#

一撃でPASS

# ls -l messages
~snip~
-rw-r--r-- 1 root root 233575 Sep 9 02:54 messages
~snip~
#

catなどでもきちんとファイル開けました。あ、もちろん手動でscp実行した時のファイルは消してrobot実行してますよ。

いくつか試し

宛先指定
get messages
    Get File  /var/log/messages  /tmp/tmp/

destinationの指定もOK。

ファイル名の変更も可能
get messages
    Get File  /var/log/messages  /tmp/tmp/vyos_messages

今回は割とスムーズにできた。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away