This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.

Kanrisuru

download

Download a file from a remote server in ruby.
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: 'centos-host', username: 'centos', keys: ['~/.ssh/id_rsa'])

host.download("/etc/hosts")
"127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4\n127.0.1.1   centos-host\n::1         localhost localhost.localdomain localhost6 localhost6.localdomain6\n\n"

This command might need escalated privlidges to access certain files that have file permissions set for root access.

Parameters

Field Type Description
remote_path string
Required path to download a file / directory
local_path string
Optional path to specify where to download. If local_path parameter isn't present, the result will be the file itself.
recursive boolean
Should download a remote directory and recursively download all of it's subdirectories
preserve boolean
The atime and mtime of the file should be preserved.

Result

Either returns the contents of the file that was downloaded if no local_path was present, or the local_path if a file or directory was downloaded successfully.

Exit Status

Code Description
0 Success
1 Failure

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES