Hi,
I'm trying to read IP and login info from a text file params.txt. The contents of the text file are:
IP = '1.2.3.4'
UID = 'anonymous'
PWD = 'my@my.com'
Upload Directory = '/'
Home Directory = 'C:/Users/MyDocuments/Python/FilesUpload/'
Can someone help me please?
import ftplib
import re
import os
import sys
import traceback
param = open("params.txt", "r")
for line in param:
if re.match("(.*)IP(.*)", line):
print ("" + re.sub('IP = ','',line))
FtpIP = re.sub('IP = ','',line)
print ("FTPIP = " + FtpIP)
ftp = ftplib.FTP()
print ("" + FtpIP)
ftp.connect(FtpIP)
File "C:\Python32\lib\socket.py", line 386, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed