Creating a python script launcher
PleegWat
pleegwat at telfort.nl
Sun Apr 11 09:44:47 UTC 2010
Jim Byrnes wrote:
> I would like to create an "application in terminal" launcher for python
> scripts. What is the command I would use to keep the terminal open so I
> can read the output of any print statements?
>
> Thanks, Jim
>
Not sure about python specifically, but normally shell scripts invoked
from a launcher do not have a terminal associated with them. You have to
explicitly invoke a terminal for the output to appear in:
gnome-terminal -x my-script
You then have to make your script wait for something, likely a keypress,
before it ends. You can also put this in your launcher command line:
gnome-terminal -x sh -c "my-script; read"
It is possible to test from a script whether a terminal is available or
not. In sh, this is done with the test command: 'test -t 2' will test if
standard error is going to a terminal. Python likely has a function to
determine this as well.
You could use this knowledge to decide whether to log to stderr or to a
file.
PleegWat
More information about the ubuntu-users
mailing list