Results 1 to 5 of 5

Thread: python console

  1. #1
    Join Date
    Mar 2005
    Beans
    305

    python console

    Is there anyway to execute another program from the python console and then have the python prompt return to do other things?

    I've tried all the methods I could find in the docs and on the net. subprocess.Popen, os.system, spawn, you name it but none of the methods I've tried allow me to do this. Perhaps I'm doing it all wrong?

    A simple example would be to start mplayer /path/movie.mkv. When I do os.system("mplayer /path/movie.mkv") I get all of mplayers output to my terminal and I don't want that

  2. #2
    Join Date
    Apr 2007
    Beans
    14,781

    Re: python console

    Can't you redirect the output to /dev/null?

  3. #3
    Join Date
    Mar 2005
    Beans
    305

    Re: python console

    All that does is remove the output, the prompt is still locked to mplayer

    import os, subprocess as sub

    os.system("mplayer /path/movie.mkv > /dev/null")
    sub.Popen("/usr/bin/mplayer " + "/path/movie.mkv > /dev/null", shell=True)

    I need something like os.system("mplayer /path/movie.mkv &")

    There has to be a way in python to do it no?

    I even tried passing it to another shell script to execute and still got mplayers output and no prompt

  4. #4
    Join Date
    Apr 2007
    Beans
    14,781

    Re: python console

    Could you try threading?

  5. #5
    Join Date
    Aug 2006
    Beans
    366

    Re: python console

    You want threading. On linux you can also run it in the background="&"
    os.system("mplayer balh blah &")
    I just tried it and you may get some startup messages, but you can then continue to enter other commands on the console. > /dev/null should eliminate the messages if you don't want them.
    Linux Counter entry # 99383 (since 1995), Feisty Xbuntu 64 bit
    Folders! We don't need no stinking folders. "I don't have anything on my machine that needs folding" -- Unknown

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •