I am new to python. I am writing a python script to find the diff between 2 html file1: beta.vidup.me-log-2016-09-21-17:43:28.html and file2: beta.vidup.me-log-2016-09-21-17:47:48.html.
To give an idea about my file organization: I have 2 directories 2016-09-21 and 2016-09-22. file1: beta.vidup.me-log-2016-09-21-17:43:28.html is present in dir1 and file2: beta.vidup.me-log-2016-09-21-17:47:48.html is present in dir2.
Below is my snippet:
dir1 = raw_input("Enter date of Archive folder to compare with in format yyyy-mm-dd---->\n")
dir2 = raw_input("Enter date of folder to compare in format yyyy-mm-dd----->\n")
now = datetime.now()
folder_output = '/home/diff_output/{}'.format(now.strftime('%Y-%m-%d'))
mkdir(folder_output)
fname1 = '/home/output/%s/beta.vidup.me-log-2016-09-21-17:43:28.html'%dir1
fname2 = '/home/output/%s/beta.vidup.me-log-2016-09-21-17:47:48.html'%dir2
# Open file for reading in text mode (default mode)
f1 = open(fname1)
f2 = open(fname2)
cmd = "diff "+fname1+'\t'+fname2
curl = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
file_data = curl.stdout.read()
print file_data
fname1.close()
fname2.close()
I wish to perform diff using the subprocess module only.
I want my code to take fname1 from dir1 and fname2 from dir2 and perform the diff and output it to a folder and Loop back to pick the next file in dir1 for fname1 and next file from dir2 for fname2 and perform the diff again.
Thanks for your time and advice in advance.
f1.close(), notfname1.close(). - Barmar