Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EXE file inside the loop
#1
I have a python loop, inside the loop, it calls an exe file.
What I want is every time when the exe file finishes the execution, then start the next iteration,
but now all the exe files runs almost together.
What should I do?

for file in folders:
  remote_path = '/miadmfggp_live/' + file
  local_path =  "C://yardi_backup//zip//"+file
  os.system("start C:\yardi_backup\yardi_download.exe {} {}".format(remote_path,local_path))
Reply
#2
It is advised to generally avoid os.system when you can and use subprocess instead to execute programs.
You might try with something like:
for file in folders:
  remote_path = '/miadmfggp_live/' + file
  local_path =  "C://yardi_backup//zip//"+file
  process = subprocess.Popen("start C:\yardi_backup\yardi_download.exe {} {}".format(remote_path,local_path))
  process.wait()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 430 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,679 Nov-07-2023, 09:49 AM
Last Post: buran
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 684 Oct-29-2023, 12:40 PM
Last Post: Mark17
  Help adding a loop inside a loop Extra 31 4,512 Oct-23-2022, 12:16 AM
Last Post: Extra
  Read xml column inside csv file with Python estertabita 2 1,353 Jul-26-2022, 06:09 PM
Last Post: Larz60+
  Adding to the dictionary inside the for-loop - weird behaviour InputOutput007 5 2,691 Jan-21-2021, 02:21 PM
Last Post: InputOutput007
  why print('\n') produced 2 new lines instead of 1 - Located inside a FOR loop JulyFire 2 2,514 Jan-10-2021, 01:50 AM
Last Post: JulyFire
  Creating a variables inside FOR loop zazas321 5 4,091 Sep-16-2020, 04:42 PM
Last Post: Naheed
  How to to tie the execution of one process to another inside a loop in Python ignorant_wanderer 0 2,041 Jul-11-2020, 03:44 AM
Last Post: ignorant_wanderer
  Updating a matrix in a time interval inside a for loop vp1989 4 2,883 May-17-2020, 07:15 PM
Last Post: vp1989

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020