In my python program i am running:
os.popen('sh download.sh')
where download.sh
downloads a couple of csv files using curl.
Is there a way to wait until the files are downloaded before the python programm continues running?
In my python program i am running:
os.popen('sh download.sh')
where download.sh
downloads a couple of csv files using curl.
Is there a way to wait until the files are downloaded before the python programm continues running?
you can solve the problem by defining the command as a subprocess:
import subprocess
p = subprocess.Popen('sh download.sh', stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
#This makes the wait possible
p_status = p.wait()
#This will give you the output of the command being executed
print("Command output: " + output)
I guess you can use "subprocess" and process.wait() function. For example:
import subprocess
your_process_name = subprocess.Popen('sh','download.sh')
your_process_name.wait()