Reputation: 400
I am new to ruby .
I have to write def , which returns the value by executing the command 'hostname -f' in a linux server. Please help me to solve this
Upvotes: 0
Views: 216
Reputation: 36860
You can call the command within backticks. Use the chomp method to remove any trailing newline.
def get_host
`hostname -f`.chomp
end
Upvotes: 1