Creating a python script launcher

Jim Byrnes jf_byrnes at comcast.net
Sun Apr 11 14:01:52 UTC 2010


PleegWat wrote:
> 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
>

The reference to the terminal came from the Launcher Properties dialog. 
  It shows two types: "Application" & "Application in Terminal"

As to my need to keep the terminal open, I was trying to understand a 
Python program. Some googling led me to believe the program was working 
but closing when it was done.  Turns out it was working just not as I 
expected. It was opening a file for writing in the same directory but 
writing it out to my home directory. When I checked to see if the file 
had been changed I looked in the original directory.

I'm new to both Ubuntu and Python so it's just something else for me to 
figure out.

Thanks,  Jim




More information about the ubuntu-users mailing list