load_env
Get user’s environment variables from system 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.load_env
result.success?
true
result['SHELL']
'/bin/zsh'
Result
Returns a hash of environment variables. Either use to_h
to access the entire hash, or the []
hash access to get individual variables.
Return Example
host.load_env.to_h
{
"SHELL" => "/bin/zsh",
"SUDO_GID" => "1000",
"SUDO_COMMAND" => "/bin/bash -c env",
"SUDO_USER" => "ubuntu" .. "PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin",
"SUDO_UID" => "1000",
"MAIL" => "/var/mail/ubuntu",
"_" => "/usr/bin/env"
}
Exit Status
Code | Description |
---|---|
0 | Success |
1 | Failure |
Tested On
- Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES