Reputation: 2039
I have a script that calls several other script and I run the script as sudo sudo ./main_script.sh
main_script.sh
#! /bin/bash
set -e
. /scritp1.sh
. /scritp2.sh
. /scritp3.sh
. /scritp4.sh
Is there any way to prevent one of the subscripts from running as sudo
? (ie. scripts 1 2 and 4 run as sudo
and script 3 run as normal)
Upvotes: 0
Views: 321
Reputation: 26442
This should achieve what you expected :
#! /bin/bash
set -e
. /scritp1.sh
. /scritp2.sh
sudo -u $SUDO_USER bash /scritp3.sh
. /scritp4.sh
Upvotes: 1