I'd like to be able to say:
./run_process.sh; sudo shutdown -P now
but the call to sudo will ask for my password and then my laptop won't shut down because it's waiting for my password. How can I pre-supply the password to sudo when I enter the command (but still run ./run_process.sh from my user account without sudo)?
You can do some "reverse psychology" here:
sudo bash -c "sudo -u dspyz ./run_process.sh; shutdown -P now"
i.e. run sudo, then "unsudo" to your process as your self (where dspyz
is your user name on that system), not as root, and then shutdown under the original sudo.
You can try this to see what it will do:
sudo bash -c 'sudo -u dspyz id; echo `id`'
where id
command shows the current user's ID and will be your (i.e. dspyz
's ID for the first id
, which plays the role of ./run_process.sh
, but will be root
for the second id
, which plays the role of shutdown -P now
).
Hope this helps.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments