Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   Switch User (http://www.programmingforums.org/showthread.php?t=15076)

kruptof Jan 28th, 2008 6:35 PM

Switch User
 
I need to switch users while performing a task, I am trying to do this with the following:
:

echo "pass" | sudo -u user | ls

However I can't seem to escape the prompt for the password, is there a way for this prompt not show up?

jim mcnamara Feb 11th, 2008 2:29 PM

Re: Switch User
 
The /etc/sudoers file dictates who is allowed to sudo to what account.
When setup up correctly:
:

sudo su - <someusername>
 ls
 exit # get out of sudo

requires no password.

If you set up so that you or whoever is running the script can sudo then the script will run without a passwoird prompt.

Dameon Feb 11th, 2008 3:43 PM

Re: Switch User
 
Quote:

Originally Posted by Manpage
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

There was some reason for the default behavior that I can't recall.


All times are GMT -5. The time now is 9:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC