3
Is there any way, under Windows 7, to emulate the behaviour of the &
character in OS X's Terminal?
I'm trying to run multiple Wget instances simultaneously: I can do this without any problem of sort under OS X, because I have a Python script which builds a long string, in which each instance of Wget is &-separated. When I execute it with os.system()
everything goes fine.
Under Windows, though, this doesn't work, and the instances are run in sequence. Which is not what I want.
I'm open to all suggestions: cmd.exe
hacks, shell ports, more Python, anything, as long as new windows shell windows are created. Thanks in advance!
Edit: I've found out that files are in fact downloaded using this method, but under Windows, cmd.exe
just ends abruptly the execution, and lets the user accept new commands. Is there any way to avoid this, and keep the console "hanging" until all Wget instances have finished downloading?
Edit 2: posting the code I'm using.
for track in album.tracks():
tracknum = track["track_num"]
tracktit = track["title"]
URL = track["file"]["mp3-128"]
filename = str(tracknum) + " - " + tracktit + ".mp3"
Now, under OS X, this code work wonderfully.
execstr += 'bandcamp-support' +os.sep+ 'wget --tries=0 -O"{}" "{}" -q & '.format(filename,URL)
os.system('bandcamp-support' +os.sep+ 'wget' execstr[:-3])
Under Windows, instead, this doesn't replicate the behaviour that I experience on OS X.
os.system('start /B bandcamp-support' +os.sep+ 'wget --tries=0 -q -O"{}" "{}"'.format(filename,URL))
http://stackoverflow.com/questions/2554514/asynchronous-subprocess-on-windows indicates it's easy to start multiple processes with https://docs.python.org/2/library/subprocess.html#popen-objects and only hard to interact with more than one concurrently. https://docs.python.org/2/library/os.html#os.spawnl and v (but not other variants) is stated to also provide an 'older' way to run processes NOWAIT on both Unix and Windows – dave_thompson_085 – 2015-11-23T04:33:13.197
Also related: How can I run an external command asynchronously from Python?
– chue x – 2015-12-23T14:53:10.7831it didnt work? What exactly did you type? – Keltari – 2013-08-07T16:14:38.910
This is the command I use for each instance of Wget:
os.system('start /B bandcamp-support' +os.sep+ 'wget --tries=0 -q -O"{}" "{}"'.format(filename,URL))
@Keltari – Jetlef – 2013-08-07T16:17:02.210I don't know for sure if it does this (because I don't really use the Windows command-line), but you should consider using powershell rather than cmd.exe, since it has more features in general. – evilsoup – 2013-08-07T16:32:37.080