Let's say we got the problem as displayed in the figure.
scriptA.py scriptB.py
get directory
modify directory
run scriptB with directory as input
-------> get directory
open .txt file
scan its contents
<------- return content to scriptA
print content
My ScriptA example is:
import os
import subprocess
if __name__ == '__main__':
directory = os.getcwd() + os.sep + 'some extension'
p = subprocess.Popen("python ScriptB.py", stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
results = p.communicate(input = str.encode(directory))[0]
print(results)
But now I'm not sure how to access the input in ScriptB. And what is necessary so communicate
detects the content which is the output of ScriptB? And is my example correct?