start external program from python

TerryP bigboss1964 at gmail.com
Mon Oct 12 12:17:55 EDT 2009


On Oct 12, 10:15 am, Bjorn <bjornj... at gmail.com> wrote:
> Hi, I woul like to start a program from within python (under linux):
> This works fine:
>
> import os
> path = 'tclsh AppMain.tcl hej.gb'
> os.system(path)
>
> The file AppMain.tcl is the executable and the file hej.gb is a
> textfile in the same directory.
> The text file gets opened in the app in the correct way.
>
> I wonder if I could pass information from the clipboard to the
> AppMain.tcl instead of the file hej.gb ?
> I use wxPython.
> any comment is appreciated!
> /bjorn

Option A.) Use a program such as xclip or xcb to pipe the clipboard
data into AppMain.tcl

Option B.) Make your Python program able to get/set the clipboard at
will, then set it before calling the program. Do like wise with
AppMain.tcl but have it get the clipboard.

Option C.) Create some external program that can do the B dance for
them.


Using option A takes advantage of your use of os.system, because it
delegates to the shell. if going for option B, you should probably
look at avoiding use of the shell at all (look at args to the
subprocess module).

Bonus points if you can think of an Option D.



More information about the Python-list mailing list