Reputation:
Just wondering how I get the hostname, i.e. the result of running 'hostname' on the command prompt, of an AWS machine (RHEL) via the Java API.
I can call the following
com.amazonaws.services.ec2.model.Instance awsInstance = ...
awsInstance.getPublicIpAddress())
awsInstance.getPrivateIpAddress())
awsInstance.getPrivateDnsName())
awsInstance.getPublicDnsName())
But cannot find out how to get the hostname - theres no getHostname() method.
Upvotes: 2
Views: 2015
Reputation:
Was able to get the hostname indirectly via:
awsInstance.getPrivateDnsName().split("\\.")[0]
Upvotes: 2