Reputation: 185
All IP address written in the file line by line and it will be executed by given command line. I want to save the result to each file with file's name is standing by each IP.
with open(list) as l:
for line in l:
file = line+".txt"
os.system("whois "+line+" >> "+file)
list contains:
192.168.0.1
192.168.0.2
192.168.0.3
Errors:
sh: 3: .txt: not found
sh: 3: .txt: not found
sh: 3: .txt: not found
Upvotes: 0
Views: 51
Reputation: 5454
You should add line = line.strip()
at beginning of your for loop to clear \n
from your line
variable, that will fix it.
Please see this answer for examples of debugging methodologies for python. In your case, a print()
statement can help you see what you are generating.
Upvotes: 3