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

mv

Move (rename) files / directories in ruby.
linux manual

Basic Usage

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

result = host.mkdir('test')
result.success?
true

host.path
'/home/ubuntu/test'

Parameters

Field Type Description
path string
Required name of the directory that is being created
owner string
integer
Owner of the directory
group string
integer
Group the directory should belong to
recursive boolean
Recursively update all sub-directories and files to the specified owner / group.
silent boolean
No error if directory already exists, make parent directories as needed
mode Kanrisuru::Mode
string
The mode bits set for the directory.

Result

Returns a single FileStat struct.

None

Return Example

host.mkdir("new-directory", owner: 0, group: 0, recursive: true).data
#<Struct:Kanrisuru::Core::Stat::FileStat:0x000006b8
  fsize = 4096,
  blocks = 8,
  device = "fc01",
  file_type = "directory",
  gid = 0,
  group = "root",
  inode = 371928,
  last_access = #<DateTime: 2021-08-25T12:17:55-05:00 ((2459452j,62275s,570593100n),-18000s,2299161j)>,
  last_changed = #<DateTime: 2021-08-25T12:17:55-05:00 ((2459452j,62275s,570593100n),-18000s,2299161j)>,
  last_modified = #<DateTime: 2021-08-25T12:17:23-05:00 ((2459452j,62243s,142213183n),-18000s,2299161j)>,
  links = 2,
  mode = #<Kanrisuru::Mode:0x1000 @numeric=775 @symbolic=drwxrwxr-x>,
  path = "/home/ubuntu/directory",
  uid = 0,
  user = "root"
>

Additional Examples

result = host.mkdir("~/make/nested/directories/", silent: true)
result.success?
true

result.path
"/home/ubuntu/make/nested/directories/"

Exit Status

Code Description
0 Success
1 Failure

Tested On

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