Page 1 of 1
How to run script to update Ddog by clicking it? (Solved)
Posted: Tue Dec 19, 2023 8:52 pm
by dcung
I created a simple script to update Ddog.
It works. But you have to either run it from a terminal or "Right click & run in terminal" to see the output in foreground.
How do I make it so that my sister can just click it and see it running (in foreground).
I think she'll forget if I tell her to 'run from terminal'.
Code: Select all
#!/bin/bash
# Filename/file location - /mnt/sda1/MyData/customise/Update-OS
echo
echo
echo
read -sp "Updating OS. Press ENTER to continue or Ctrl-C to Cancel. . ."
echo
echo
apt update
#apt upgrade -y #Comment out during test
echo
echo
read -sp "Update completed. Press ENTER to continue."
echo
Code: Select all
[Desktop Entry]
Version=1.0
Type=Application
Name=Update OS
Comment=
#Exec=/mnt/sda1/MyData/customise/Update-OS #or below
Exec=xterm -e "bash -c '/mnt/sda1/MyData/customise/Update-OS'"
Icon=/root/icons/terminal.png
Path=
Terminal=true
StartupNotify=false
Categories=Application;
Sort of like what this guy is trying to do.
And the replies didn't address the question (?).
https://askubuntu.com/questions/138908/ ... in-windows
.
.
If it's too hard, I'll probably just try to teach her right-click & 'run in terminal' ![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Simple script - help
Posted: Tue Dec 19, 2023 9:37 pm
by fredx181
@dcung
If the purpose is to run it by 'just clicking the script', one way is to run it from xterm (if installed) with exported function run_in_xterm :
(can't see btw why the .desktop launcher code you posted won't work (it should work with Terminal=true
) but perhaps better leave out the (empty) Path=)
EDIT: or perhaps better make Exec= simply Exec=/mnt/sda1/MyData/customise/Update-OS
(combined with Terminal=true it should run from the default terminal)
Anyway, clickable script to run from xterm:
Code: Select all
#!/bin/bash
# function run_in_xterm
run_in_xterm () {
# Filename/file location - /mnt/sda1/MyData/customise/Update-OS
echo
echo
echo
read -sp "Updating OS. Press ENTER to continue or Ctrl-C to Cancel. . ."
echo
echo
apt update
#apt upgrade -y #Comment out during test
echo
echo
read -sp "Update completed. Press ENTER to continue."
echo
}
export -f run_in_xterm
# run function 'run_in_xterm' from xterm
xterm -T "Update-OS" -e /bin/bash -c run_in_xterm
Re: Simple script - help <SOLVED>
Posted: Tue Dec 19, 2023 9:48 pm
by dcung
fredx181 wrote: Tue Dec 19, 2023 9:37 pm
@dcung
If the purpose is to run it by just clicking on the script, one way is to run it from xterm (if installed) with exported function run_in_xterm :
(can't see btw why the .desktop launcher code you posted won't work (it should work with Terminal=true
) but perhaps better leave out the (empty) Path=)
EDIT: or perhaps better make Exec= simply Exec=/mnt/sda1/MyData/customise/Update-OS
(combined with Terminal=true it should run from the default terminal)
The code you provided is exactly what I was looking for and it works. ![Thumbup :thumbup:](./images/smilies/thumbup.gif)
I also tried the .desktop way, still didn't work.
The link I provided above also seems to suggest it should work.
But it didn't for me. Will tinker again. Not surprised if I found it was my fault later.