If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I know that if I open up the Terminal and do
$ sudo blahblahblah
I get a prompt for my password. Is there anyway, though, to run sudo from within a shell script and somehow enter my password in the same line?
I mean something along the lines of
sudo whatever -p mypassword
(Yes, I know -p is not for entering my password)
No, because it's a bad idea.
Either use 'sudo' in the script and supply your password when requested, or write a two-line C program that calls your script, compile it, and then make it owned by root and turn on the setuid bit.
Better yet edit the /etc/sudoers file (using: sudo visudo) to permit the action you are trying to perform without a password. sudo is designed to give selective access to things with and without a password as desired. man sudoers and man sudo might be useful in working out what exactly to put in the file.