using text file to get ip address from hostname
Dan Katorza
dkatorza at gmail.com
Wed Sep 19 03:41:36 EDT 2012
בתאריך יום ראשון, 16 בספטמבר 2012 01:43:31 UTC+3, מאת Dan Katorza:
> בתאריך יום רביעי, 12 בספטמבר 2012 17:24:50 UTC+3, מאת Dan Katorza:
>
> > hello ,
>
> >
>
> >
>
> >
>
> > i'm new to Python and i searched the web and could not find an answer for my issue.
>
> >
>
> >
>
> >
>
> > i need to get an ip address from list of hostnames which are in a textfile.
>
> >
>
> >
>
> >
>
> > this is what i have so far
>
> >
>
> > --------------------------------------------------------------------------
>
> >
>
> > #!/usr/bin/env python
>
> >
>
> > #Get the IP Address
>
> >
>
> >
>
> >
>
> > import socket
>
> >
>
> > hostname = 'need it to read from a text file'
>
> >
>
> > addr = socket.gethostbyname(hostname)
>
> >
>
> > print 'The address of ', hostname, 'is', addr
>
> >
>
> >
>
> >
>
> > ---------------------------------------------------------------------------
>
> >
>
> >
>
> >
>
> > any idea ?
>
> >
>
> > sorry for my english
>
> >
>
> >
>
> >
>
> > thanks.
>
>
>
> Hi Hans,
>
> thank you very much for the tips.
>
> as i mentioned before I'm new to python and I'm trying to learn it step by step.
>
> thank you for showing me other ways, i will explore them.
Hello again,
I have another question and i hope you will understand me..
Is there any option where you can set the program to go back to lets say the top of the code?
I mean if the program finished the operation and i want to stay in the program and go back ro the start.
after any operation i want the option to do it again , go back to the main menu or full exit from the program, and i want it every time.
i hope i'm clear :)
More information about the Python-list
mailing list