Windows: equivalent of OS X's Terminal "&"

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))

Jetlef

Posted 2013-08-07T16:07:31.270

Reputation: 33

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.783

1it 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.210

I 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

Answers

1

If you are a fan of *NIX shells, you can install Cygwin and have access to all those shells and tools with Cygwin. Ot you can just install a Bash shell with Win-Bash. However, I think you would be better off with Cygwin, as it has a lot of functionality.

Keltari

Posted 2013-08-07T16:07:31.270

Reputation: 57 019

1Cygwin is interesting, but it requires a lot of DLLs... isn't there a single binary file out there? Or a way to pack it into a binary myself? Now I know why all programmers use Linux/OS X... and why everyone hates Windows. :D – Jetlef – 2013-08-07T16:36:32.090

1I highly recommend Cygwin, worst case you can uninstall it. Its stable and you can get all the *NIX tools you can ever want. Wget isnt part of the base package, you can search for it (get the one under web tools, which is the full application, not the Perl based implementation). – Keltari – 2013-08-07T16:48:36.497

Ah, I give up. Windows' scared another one away. I guess what I want to do can be somehow accomplished using these techniques: Wait the end of subprocesses with multiple parallel jobs, but I'd need to adapt those examples to Windows, and I'm just tired of doing this.

– Jetlef – 2013-08-07T17:00:17.703