Kanrisuru

whoami

Print the effective user id 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.whoami
result.success? 
true

result.user
"ubuntu"

Parameters

None

Result

Returns a UserName struct.

UserName Fields

Field Type Description
user string The user name of the current effective user

Return Example

host.whoami.data
#<Struct:Kanrisuru::Core::Path::UserName:0x000005c8
  user = "ubuntu"
>

Exit Status

Code Description
0 Success
1 Failure

Tested On

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