#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Location
    east coast
    Posts
    20
    Rep Power
    0

    Python 2.7.3 os.system("")


    hi
    i wrote a small button window to try and automate somethings i do repetitively, all on the same server :
    start a server wol <<<button 1
    mount a share <<<<button 2
    unmount a share <<<<button 3
    start webmin in firefox <<<<button 4
    ssh into a server <<<<button 5

    i have the button set up activebackground='green' so when i press the mount share
    button it turns green while python carries out my code. witch is fine with most things i'm doing but when my code starts an external program it hangs my code till i close the program i had python open

    Code:
     def ab2 (self):
                    os.system("x-terminal-emulator -e /home/klein/places/acronq/scripts/2400_mnt.sh")
                    os.system("keepnote")
    my question is is there a way to do this without hanging my program ?

    in python ide if i run os.system("keepnote") it starts the program and returns 0 then back to the prompt.

    Code:
    if i open keep note from a terminal it holds the terminal with this:
    klein@lg1:~/Desktop$ keepnote
    
    ==============================================
    KeepNote 0.7.8: Sat Apr 20 08:15:19 2013
    enabling extension 'notebook_http'
    enabling extension 'backup_tar'
    enabling extension 'new_file'
    enabling extension 'editor_insert_date'
    enabling extension 'command_basics'
    enabling extension 'export_html'
    enabling extension 'python_prompt'
    enabling extension 'keepnote'
    if i close the terminal it terminates keepnote if i close keep note it gives me the prompt back in terminal is there a solution ?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,851
    Rep Power
    481
    Of many solutions, the easiest is to stick an ampersand at the end of the command. See this reference.

    os.system("x-terminal-emulator -e /home/klein/places/acronq/scripts/2400_mnt.sh &")

    os.system("keepnote &")

    os.system("nohup keepnote >&/dev/null &")
    os.system("( keepnote & ) &")

    The other solutions I referred to would be python solutions.


    or, in Windows

    os.system("start notepadPlusPlusPlus")
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Location
    east coast
    Posts
    20
    Rep Power
    0
    b49P23TIvg

    it worked like a charm !!!!!!

    thank you i have another question but i will start another thread

IMN logo majestic logo threadwatch logo seochat tools logo