Tech Support Guy banner
Status
Not open for further replies.
1 - 1 of 1 Posts

·
Registered
Joined
·
8 Posts
Discussion Starter · #1 ·
Hi,

This is a small script that i am trying to get to execute. It should take the hosts in the first for loop and then for that host process the name in the list stored at c:\fldrname.txt file. But the code just executes the first host and stops the second one is not taken. Why?:confused: Any and all help is appreciated?

Code:
import string	
ourfile = r'c:\fldrname.txt'
hosts = ['a', 'b']
fldrlistfile = file(ourfile)
for x in hosts:
    for i in fldrlistfile.readlines():
        fldr = i.split('\n')
	print x + fldr[0]
fldrlistfile.close()
-----------------
Editing this since i got it to work. It seems assigning the fldrlistfile.readlines() to a variable did the trick.

Code:
import string	
ourfile = r'c:\fldrname.txt'
hosts = ['a', 'b']
fldrlistfile = file(ourfile)
z = fldrlistfile.readlines()
for x in hosts:
    for i in z:
        fldr = i.split('\n')
	print x + fldr[0]
fldrlistfile.close()
 
1 - 1 of 1 Posts
Status
Not open for further replies.
Top