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

which

Show the full path of a shell command in ruby with which.
linux manual

Basic Usage

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

result = host.which('cat', all: true)
result.success? 
true

result.map(&:path)
['/usr/bin/cat', '/bin/cat']

Parameters

Field Type Description
program_name string
Required name of program to get full path of
all boolean
Gets all matching executables, not just the first

Result

Returns an array of FilePath structs.

FilePath Fields

Field Type Description
path string Symbolic or absolute file path

Return Example

host.which('cat')[0]
#<Struct:Kanrisuru::Core::Path::FilePath:0x00000618
  path = "/usr/bin/cat"
>

Exit Status

Code Description
0 Success
1 Failure

Tested On

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