Windows subprocess.call problem

Discussion in 'Python' started by Tom Borkin, Jan 21, 2013.

  1. Tom Borkin

    Tom Borkin Guest

    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
    Tom Borkin, Jan 21, 2013
    #1
    1. Advertising

  2. Tom Borkin

    Nobody Guest

    On Mon, 21 Jan 2013 07:25:06 -0400, Tom Borkin wrote:

    > 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)
    Nobody, Jan 21, 2013
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Golden
    Replies:
    0
    Views:
    175
    Tim Golden
    Nov 18, 2012
  2. Chris Rebert
    Replies:
    0
    Views:
    214
    Chris Rebert
    Nov 18, 2012
  3. Dave Angel
    Replies:
    0
    Views:
    171
    Dave Angel
    Nov 21, 2012
  4. Tim Golden
    Replies:
    0
    Views:
    130
    Tim Golden
    Nov 21, 2012
  5. Prasad, Ramit
    Replies:
    0
    Views:
    161
    Prasad, Ramit
    Nov 23, 2012
Loading...

Share This Page