Sending stdin to subprocess in python script
Question: I have a python script which requires the opening of another terminal window
to send some commands. Stackoverflowers have already gotten me that far:

    
    
    import subprocess
    server_terminal = subprocess.Popen(['open','-a','/Applications/Utilities/Terminal.app','/Applications/Utilities/Terminal.app']) #Not sure about the inelegance of the doubled path, but it does open another terminal window, which I need.
    

The next step that I need is to send this terminal some commands so that I can
get a local server set up on the user's desktop. Having some significant
troubles figuring how to control this subprocess.

Can anyone direct me to the method I would use to make this terminal
subprocess take stdin from me? I would prefer to avoid 3rd party modules.

Edit: Some context -- My major goal is to open a [selenium
server](http://seleniumhq.org/) in a separate terminal window so that I can
issue it commands. I already know how to control the server once it's started,
I just can't figure out how to automatically start one.

Thanks for all your help!


Answer: You can use `Popen` to start the server directly:

    
    
    selenium_jar = '/full/path/to/selenium-server-standalone-2.0b3.jar'
    path_to_fifo_profile = '...'
    
    # start external process
    p = subprocess.Popen(['java', '-jar', selenium_jar, 
                                  '-firefoxProfileTemplate', path_to_fifo_profile,
                         ])
    # wait for it to finish before exiting
    p.wait()
    

If you want to see the output, you can use `os.system` instead:

    
    
    os.system('java '
              '-jar /path/to/selenium-server-standalone-2.0b3.jar '
              '-firefoxProfileTemplate /path/to/profile')
    

