Reputation: 4510
I have a wrapper script which calls two scripts aaa.sh and bbb.sh. These two scripts should be executed as different users as
sudo -H -u user1
. /user/bin/scripts/aaa.sh
sudo -H -u user1
. /user/bin/scripts/bbb.sh
but the sudo command can't be executed inside a script. Need help...
Upvotes: 1
Views: 7353
Reputation: 81
sudo can be used only if the user name is mapped in /etc/sudoers file as mentioned above. But he may not have the complete priveleges as compared to su user.
Upvotes: 0
Reputation: 435
sudo
can be used inside a script, but is the user that executes this script actually allowed to use sudo
? Check your /etc/sudoers
file.
Upvotes: 0
Reputation: 128
If you just want to switch users, you should use 'su' not sudo, right?
su user1 -c ./user/bin/scripts/aaa.sh
(that is unless you actually do need elevated privileges)
Upvotes: 1