Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 28th, 2008, 6:35 PM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 317
Rep Power: 3 kruptof is on a distinguished road
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?
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Feb 11th, 2008, 2:29 PM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 3 jim mcnamara is on a distinguished road
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.
jim mcnamara is offline   Reply With Quote
Old Feb 11th, 2008, 3:43 PM   #3
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 729
Rep Power: 4 Dameon is on a distinguished road
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.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow user to select a directory MegaArcon HTML / XHTML / CSS 11 Jun 5th, 2006 8:38 AM
problem with user defined class mixed with functions willj729 C++ 4 Oct 9th, 2005 3:26 PM
User Input for Number Format ericelysia1 Java 0 Jul 21st, 2005 3:41 PM
Loading and Destroying web user controls into a panel see07 C# 0 Feb 2nd, 2005 12:38 PM
Show web user control hidden see07 C# 1 Feb 2nd, 2005 10:35 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:42 AM.

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