I have run into a situation where I need to write commands to the command line and they need to be executed by root. Now, I know I can do something like
echo rootpassword | sudo -S mycommands
but the problem is that the user this would be issued from would not be in the /private/etc/sudoers file and I dont want to have to append it with the user I am issuing it from. So, since the user I am using is NOT in this file I tried something like
echo rootpassword | su -l root; MyOtherCommands
but I need to know the proper syntax to trick the su password to read from where the echo is being written to. Its kinda confusing but thought someone here would know the answer to this one.
Comments are closed