Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-21-2003, 07:22 PM   #1
LQ Newbie
Registered: Oct 2003
Location: San Antonio, Tx
Distribution: SuSE 8.1 Prof
Posts: 4

Rep: Reputation: 0
shell script switching user question

Hello. I'm in need of a shell script that can switch users. However, I can't seem to get it to work. It will execute the su command but it keeps prompting me for a password. How do I pass this in? I'm writing this in php, so here's what i've tried so far:

exec("su userid -c pass");
exec("su -c user id pass");
exec("su -c user id 'pass'");

If someone could let me know what i'm doing wrong or point to a site that show me it would be greatly appreciated! Thanks in advance!
Old 11-22-2003, 10:03 AM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Welcome to LQ.

I don't think you can pass a password as an argument.

A few possible solutions:
Check if you can run your command setuid.
Write an expect script to run su.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 04:14 AM
Running script as user that does not have shell sschueller Linux - General 1 04-24-2004 04:06 PM
Shell script that changes user davholla Linux - General 2 03-23-2004 10:18 PM
changing user in a shell script sanjith11 Programming 6 03-22-2004 02:18 PM
shell script user not ok slam Linux - General 4 07-24-2003 07:40 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:22 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