I am using following code to find the hostname/dns name of a linux server.
And the name of the server gets printed as XXX. And I am trying assign this value to $host as below. But it is not working and $host name is null. How do I assign XXX to $host.
Please let me know. Thanks.
Code:
(grep {chomp;} system ('hostname -s'))[0];
Code:
$host =(grep {chomp;} system ('hostname -s'))[0];
print "The host name is $host \n";
Comment