I need a script to create a screen session and run a command inside, then detach and proceed with other screens. So I need something like screen -S vault -d -m $HOME/vault/v.sh
. However, v.sh
requires sudo privileges. What are my options?
- Leave it like that and run the whole script as
sudo
. Problem: the other scripts/sessions will also run assudo
, which is undesirable. - Insert
sudo
at the start:sudo screen -S vault -d -m $HOME/vault/v.sh
. - Insert it before calling
v.sh
:screen -S vault -d -m "sudo $HOME/vault/v.sh"
What is the best option?