Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-06-2003, 02:35 PM   #1
LQ Newbie
Registered: Aug 2003
Distribution: Redhat
Posts: 1

Rep: Reputation: 0
run command as alternate user

I need to be able to run an arbitrary command as an arbitrary user without providing any feedback such as a password after the initial invocation. i've looked at su and sudo and runas but they seem like they won't accomplish what I need. I'm looking for something along the lines of
su -l mylogin -p myPassword -e "myProc"

any suggestions? Much thanks on this.
Old 08-06-2003, 04:31 PM   #2
Registered: Feb 2003
Location: Atlanta, GA
Distribution: RHAS 2.1, RHEL3, RHEL4, SLES 8.3, SLES 9, SLES9_64, SuSE 9.3 Pro, Ubuntu, Gentoo
Posts: 335

Rep: Reputation: 32
You should be able to do su -l USER -c some_command i.e. su -l bob -c ls /home/bob You will still have to provide a password. You could write a script using expect and feed the password to the command line that way. Fairly easy in perl and I would guess bash can do it also.

One thought, if you were logged in as root, you do not have to provide a password to execute commands as another user. So the su -l bob -c ls /home/bob would work without prompting for a password. You could make a script that ran the commands as each user and fire it off as root and it won't prompt you.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
run command as user BFEINZIMER Linux - Newbie 9 08-24-2005 10:21 PM
run mount command as user paul_mat Linux - Newbie 1 12-14-2004 06:28 PM
How to run a command on new mail for a user? pembo13 Linux - Networking 0 09-26-2004 07:37 AM
How do I give a user to run the nice command? badmofo666 Linux - Newbie 3 03-17-2004 07:01 PM
Is their a way to run a command as root..or another user.. in php BaerRS Programming 2 04-25-2002 02:38 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration