-1

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?

Los
  • 111
  • 6

2 Answers2

0

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)
mzr97
  • 69
  • 7
0

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()
mrbravo
  • 11
  • 2