Windows subprocess.call problem

T

Tom Borkin

Hi;
I have this code:

#!/Python27/python
import os, subprocess, sys
lyrics_path = "/Users/Tom/Documents/lyrics"
os.chdir(lyrics_path)

songs = ['livin-la-vida-loca', 'whos-that-lady']
for song in songs:
subprocess.call(['notepad.exe', '%s.txt' % song])
my_songs_path = "aa english lyrics"
os.chdir(my_songs_path)
for song in my_songs:
subprocess.call(['notepad.exe', '%s.txt' % song])
print song

It opens the first song and hangs on subsequent songs. It doesn't open the
next song or execute the print until I have closed the first one. I want it
to open all in the list, one after another, so I have all those songs
available. Please advise.
TIA,
Tom
 
N

Nobody

It opens the first song and hangs on subsequent songs. It doesn't open the
next song or execute the print until I have closed the first one. I want it
to open all in the list, one after another, so I have all those songs
available. Please advise.

If you want to be able to keep track of the child process (e.g. to
determine when it has finished), use subprocess.Popen(). If you just want
to "fire and forget", use the "start" shell command, e.g.:

subprocess.call(['start', 'notepad.exe', '%s.txt' % song], shell=True)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top