The subprocess calls Diffutils which takes two files.
Diff.exe 1.txt 2.txt
And returns the differences between them.
The following code works...
process = subprocess.Popen(relativePath1 + 'diff.exe ' + relativePath + '/1.txt ' + relativePath + '/2.txt', cwd=relativePath1, stdout=subprocess.PIPE)
process.wait()
print(process.stdout.read().decode())
I'd like to replace relativePath + '/1.txt ' + relativePath + '/2.txt'
with strings instead of file destinations.
I found this similar post Python string as file argument to subprocess which takes in one argument ... but could not get this to work passing two strings to replace the two paths requested by diff.exe.
One = 'bla bla bal bla'.encode()
Two = 'bla xxx bal bla'.encode()
p = subprocess.Popen([relativePath1 + 'diff.exe'], shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=[subprocess.PIPE, subprocess.PIPE])
p.communicate(input=One, Two)