LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   run command as alternate user (https://www.linuxquestions.org/questions/linux-general-1/run-command-as-alternate-user-79595/)

joeca 08-06-2003 02:35 PM

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.

TheOther1 08-06-2003 04:31 PM

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.

HTH!


All times are GMT -5. The time now is 08:36 AM.