As part of a start script I need to check to see if a particular TCP service is actually up and running. By reading a config file I know what the target host and service name is. I intended to use nc to send a sample request to this service, because I know how to use it and it scripts well, the problem is that nc cannot resolve the service name in my config to a port number...
Which brings me to my (2-part) question: Is there a bash built-in or commonly distributed utility (would be part or a RHEL 5 distro) which can resolve the service name to a port number? Is there a simple utility other than netcat which I could use in my script instead?
getent is what you want.
For instance: getent services ftp
You'll need to parse the output anyway, but you have the port.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With