I have two utilities written in C++, TCP/IP server and client that I have used for years.
Server opens designated file and waits for client to connect. After connection has been established the server starts to send file’s content. The client receives it and saves in a file.
Now, I want to write a python script to start both application and wait for them to finish. After that script will do some other work. It is written for Windows.
It is my first script in python. And my first problem is that I can see that both applications have started and connected to each other. I can see it because two DOS windows appears and show messages that inform me about connection.
However, I don’t see a file, which has to be created by the client. What is wrong. Code is very simple and follows.
import subprocess
p = subprocess.Popen('C:\MyProjects\exes\FeedSender_exe\FeedSender.exe C:\MyProjects\exes\FeedSender_exe\FeedSender.ini')
print "Start1"
p1 = subprocess.Popen('C:\MyProjects\exes\FeedReaderFileProcessor\FeadReaderi41.exe C:\MyProjects\exes\FeedReaderFileProcessor\Config.ini')
print "Start2"
for line in p.stdout.readlines():
print line,
retval = p.wait()
print "Finish1"
retval = p1.wait()
print "Finish2"
It will probably help to set the subprocess’s current working directory.
Depending on how you set up your programs, the output file should show up in
C:\MyProjects\exes\FeedSender_exe. I obviously can’t get your programs, so I can’t test this.