rmdir
Remove an empty directory 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.rmdir('empty-directory')
result.success?
true
Removing the root directory, '/' is disabled with Kanrisuru rmdir command.
Parameters
| Field | Type | Description |
|---|---|---|
| paths |
string
array
|
Required name of the directory entries to remove |
| parents |
boolean
|
Remove directory and it's ancestors. |
| silent |
boolean
|
Ignore each fialure is because a directory is non-empty. |
Result
No explicit data struct returned, only option is success?, failure?, and status to see if the program exited properly.
Return Example
host.ls(path: 'directory').map(&:paths)
[
'1/',
'2/',
'3/',
'4/'
]
host.rmdir(['directory/1', 'directory/2', 'directory/3']).success?
true
host.rmdir('directory', silent: true).success?
true
host.rmdir('directory/4', parents: true).success?
true
Exit Status
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Failure |
Tested On
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES