Hello all I am a new user , installed linux due to lack of space to upgrade windows. i wish i had made the move years ago.
i am running the following -
Operating System: Linux Mint 21.1
Kernel: Linux 5.15.0-72-generic
Architecture: x86-64
Hardware Vendor: HP
Hardware Model: HP Stream Notebook
i want to run a launcher to automatically check and update my system and have got this far -
sh -c 'sudo apt update && sudo apt upgrade && $ echo "Finished"'
it will run the update and upgrade sections work correctly but it then closes terminal and I am never able to see if it has completed properly.
Can anyone point me in the right direction please
[SOLVED] launcher commands issue
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
[SOLVED] launcher commands issue
Last edited by LockBot on Mon Nov 27, 2023 11:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: launcher commands issue
There's an extraneous
This waits for <enter> to close the terminal.
And since you're new: this might also be a good time to mention that on Debian/Ubuntu/Mint
$
there which I'll assume is a typo/copypaste-o. I'll also assume you have the launcher set to "execute in terminal" (detailed formulation is desktop environment specific), and I'd recommend to just use the standard Upgrade Manager instead -- but a direct answer is stringing a read
onto your command:Code: Select all
sh -c 'sudo apt update && sudo apt upgrade; read -p "Finished " tmp'
And since you're new: this might also be a good time to mention that on Debian/Ubuntu/Mint
/bin/sh
is dash rather than bash, which is to say that if you ever want/need to use a bash-specific construct you need to explicitly say bash -c '...'
. Here it doesn't matter (although bash has slightly nicer syntax for read
that doesn't need the tmp
throw-away variable).Re: launcher commands issue
Some terminal emulators have a flag which prevents this behavior, but failing that, you can:
Code: Select all
sh -c 'sudo apt update && sudo apt upgrade; echo "Press Enter to continue... "; read _'
$
, as it'd almost certainly result in a 'command not found' error. I've also adjusted the logic, because you presumably want the prompt to display regardless of the status of the previous command. Both &&
and ||
are logical operators for AND and OR, respectively, while ;
essentially acts as a new line.This is why the following is a common convention for an
if
statement:Code: Select all
if LIST; then
LIST
fi
Code: Select all
if LIST
then
LIST
fi
;
, &&
, and ||
will help a lot.Below,
Command_B
will execute regardless of the success of the previous command.Code: Select all
Command_A; Command_B
Command_B
will execute only if Command_A
succeeded.Code: Select all
Command_A && Command_B
Command_B
will only execute if Command_A
fails.Code: Select all
Command_A || Command_B
Lastly, you might prefer:
Code: Select all
sudo sh -c 'apt update && apt upgrade; echo "Press Enter to continue... "; read _'
I'm also Terminalforlife on GitHub.
Re: launcher commands issue
thank you
everything is good now
I appreciate the help
everything is good now
I appreciate the help