Clickable script to run in terminal

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
Wognath
Posts: 423
Joined: Sun 19 Apr 2009, 17:23

Clickable script to run in terminal

#1 Post by Wognath »

Hello
Back in 2010, rcrsn51 wrote,
You may have scripts that you use regularly, but must open a terminal window to run them. Here is a simple method for making a script clickable. You can then put a shortcut to the script on your desktop.

Just place the following three lines at the top of the script (without any blank lines):
Code:
#!/bin/sh
tail -n +4 $0 > /tmp/script.txt
exec rxvt -e sh /tmp/script.txt
This has been very useful for me in my Linux tinkering since I can click a script and have it run itself in a terminal for input and output.

I recently stumbled on a simple alternative that seems to work:

Code: Select all

#! /bin/bash
[ -t 0 ] || exec rxvt -e $0
rest of the script 
I wonder if there are pitfalls to this that I should know about?
Are there are other neat ways to accomplish the same?

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Clickable script to run in terminal

#2 Post by MochiMoppel »

Wognath wrote:I wonder if there are pitfalls to this
Karl Godt voiced strong objections in this thread ("No way is test -t $X the solution !")
IMO his arguments do not apply.

Post Reply