Using python through ansible I gathered a list of 7000 hostnames from DNS, but I want to prompt the user to enter a hostname and in return, the hostname will appear if present.
But it should be optional whether to look at the whole list or just one specified hostname.
The script is executed in xshell 5.
Any idea how I can proceed?
One way you could do this would be using
input
(python3) (orraw_input
(python2)) or specifying hostname as an argument to your script. You could get output from all by not specifying any hostname.Assuming your hostnames are in a python list
dnshostnames
:input
:or as argument to script:
which would then be called as
python myscript.py myhostname