Page 1 of 1

Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 4:20 am
by mivison

Lets say I have a case statement and I want to execute it by clicking on a Rox bash file. But I want it to open up in a terminal.
What can I add to this code to do this?
Here is the sample script,

#!/bin/bash
#Mike Ivison
# Date 2/22/2021
clear
echo 'a = Date and Time'
echo 'b = List file and directories'
echo 'c = List users logged in'
echo 'd = SYSTEM UPTIME'
echo
read choices
case $choices in
a) date;;
b) ls;;
c) who;;
d) uptime;;
*) echo Invalid choice - Bye.

esac


Re: Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 5:09 am
by mivison

I found the "xterm -hold -e" flag that works. Is there a better way?


Re: Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 7:48 am
by wiak

You might find the following two alternatives also useful (though not relying on keeping a terminal open):

Code: Select all

some_piped_or_simple_commandline | leafpad

some_piped_or_simple_commandline | Xdialog --title "whatever" --no-cancel --fixed-font --textbox - 40 80

e.g.

ls | leafpad

ls -al | sort | Xdialog --title "sorted dir list" --no-cancel --fixed-font --textbox - 40 80

Code: Select all

read choices
case $choices in
a) date | leafpad;;
b) ls | leafpad;;
c) who | Xdialog --title "who" --no-cancel --fixed-font --textbox - 40 80;;
d) uptime | Xdialog --title "uptime" --no-cancel --fixed-font --textbox - 40 80;;
e) cal | leafpad;;
*) echo Invalid choice - Bye. | Xdialog --title "invalid choice" --no-cancel --fixed-font --textbox - 40 80
esac

Re: Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 10:07 am
by MochiMoppel
mivison wrote:

I found the "xterm -hold -e" flag that works. Is there a better way?

What means "better"? Faster , shorter, easier?
xterm may not be the best choice, but if it works for you this shouldn't matter.
-hold may also be a questionable option here.
Please explain how you use the xterm command in your script. Without this info it's hard to tell if there are better ways.


Re: Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 1:12 pm
by mivison

Thanks all. for the imput. I'm just learning bash stuff right now? My goal right now is to manipulate MPV video player with some bash scripts.


Re: Rox filer, executing a bash script in an open terminal?

Posted: Tue Mar 09, 2021 5:47 pm
by mivison
wiak wrote: Tue Mar 09, 2021 7:48 am

You might find the following two alternatives also useful (though not relying on keeping a terminal open):

Code: Select all

some_piped_or_simple_commandline | leafpad

some_piped_or_simple_commandline | Xdialog --title "whatever" --no-cancel --fixed-font --textbox - 40 80

e.g.

ls | leafpad

ls -al | sort | Xdialog --title "sorted dir list" --no-cancel --fixed-font --textbox - 40 80

Code: Select all

read choices
case $choices in
a) date | leafpad;;
b) ls | leafpad;;
c) who | Xdialog --title "who" --no-cancel --fixed-font --textbox - 40 80;;
d) uptime | Xdialog --title "uptime" --no-cancel --fixed-font --textbox - 40 80;;
e) cal | leafpad;;
*) echo Invalid choice - Bye. | Xdialog --title "invalid choice" --no-cancel --fixed-font --textbox - 40 80
esac

Thanks, I'm wanting to use A dialog at some piont. I guess now is a good a time as any!