|| at Jun 7, 2011 at 1:55 am
Is there a library or regex that can determine if a string is a fqdn
(fully qualified domain name)? I'm writing a script that needs to add
a defined domain to the end of a hostname if it isn't already a fqdn
and doesn't contain the defined domain.
You might try the os module and then use something like nslookup.
The output is sent on the subprocess standard out... so you can grab it
with piping, or redirect, or redirect to a file and read later, etc.
You might also try the subprocess module. It provides better flexibility
and control for handling the output of the nslookup, or whatever tool
you decide to use to find the fully qualified name.