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

interpretive language scripts


Moderator: Forum moderators

Post Reply
mivison
Posts: 27
Joined: Tue Nov 24, 2020 5:43 pm
Has thanked: 4 times

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

Post 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

mivison
Posts: 27
Joined: Tue Nov 24, 2020 5:43 pm
Has thanked: 4 times

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

Post by mivison »

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

User avatar
wiak
Posts: 4125
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1227 times
Contact:

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

Post 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

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

User avatar
MochiMoppel
Posts: 1249
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 22 times
Been thanked: 448 times

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

Post 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.

mivison
Posts: 27
Joined: Tue Nov 24, 2020 5:43 pm
Has thanked: 4 times

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

Post 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.

mivison
Posts: 27
Joined: Tue Nov 24, 2020 5:43 pm
Has thanked: 4 times

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

Post 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!

Post Reply

Return to “Scripts”