You are not logged in.
Pages: 1
Hi everyone,
I would like when double click on a .sh file to run it interactively , is it possible ?
At the moment when I double click on it's running in the background (aka non-interactively)
The best method would be to edit the .sh file (like I can choose which one need to be interactive or not..)
Thanks.
Last edited by SpongB0B (2022-06-20 11:59:21)
Linux noob, plz be kind
Offline
I've tried this
if [ -z "$PS1" ]; then
echo This shell is not interactive
echo -e "$(pwd)/$BASH_SOURCE \n"
xfce4-terminal -T "test" -x $BASH_SOURCE
exit
else
echo This shell is interactive
echo -e "$(pwd)/$BASH_SOURCE \n"
fi
But this launch an infinite / loop a new terminal
Linux noob, plz be kind
Offline
First off, you need to explicitly tell Thunar to execute shell scripts instead of opening them:
xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true
Next, you need to create a .desktop entry for it and enable running in a terminal. The default Menu Editor app will let you do this easily.
The interactivity itself will depend on the utility (i.e. command) you're invoking.
If your scripts handles this and waits for user input (with read), then you'll be able to interact with the script. If it's just a simple command, such as:
cp file1 file2
then of course you won't get any interactivity at all.
EDIT: another way is to put
xfce4-terminal --hold --command='command'
in your script. This will open a terminal window whenever you launch the script and be kept open until you close it.
Last edited by KBar (2022-06-20 09:44:59)
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
Thank you @KBAR !
I made some test and I came up with this (work well in my case)
if [ $WINDOWID -gt 0 ] ; then
echo "launched from terminal $WINDOWID"
else
coproc xfce4-terminal -T "Icon launch" -x $BASH_SOURCE
exit
fi
Linux noob, plz be kind
Offline
Pages: 1
[ Generated in 0.009 seconds, 8 queries executed - Memory usage: 527.6 KiB (Peak: 528.52 KiB) ]