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! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-08-2004, 11:21 PM
|
#1
|
|
Member
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59
Rep:
|
Execute a command as another user
I am logged in as root. I want to execute a command as another user ($USER).
I am trying to do this from a command line with no scripting and all on one line.
This is for qmail for the ./Maildir/ functionality.
Does anyone have any ideas?
Thanks in advance
|
|
|
|
06-08-2004, 11:30 PM
|
#2
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
I think you should be able to do something like "su -c MYCMD".
You can look up the details in "man su".
|
|
|
|
06-08-2004, 11:33 PM
|
#3
|
|
Member
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59
Original Poster
Rep:
|
Yeah, thats what I have been trying, but either I am an idiot (very possible here) or what I am trying to do is not possible.
Here is what I am trying...
su - user -c /var/qmail/bin/maildirmake ~/Maildir
The problem is that the command is not accepting anything after the space.
|
|
|
|
06-08-2004, 11:37 PM
|
#4
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Try putting the command in quotes:
su - MYUSER -c "/var/qmail/bin/maildirmake ~/Maildir"
PS:
Apologies in advance, but I'm booted to Micro$oft at the moment, so I can't test it out myself...
|
|
|
|
06-08-2004, 11:38 PM
|
#5
|
|
Member
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59
Original Poster
Rep:
|
Tried that too...didn't work.
|
|
|
|
06-08-2004, 11:43 PM
|
#6
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Sorry. Even though you said you didn't want to (or couldn't) go that route, it would be work it to wrap the "maildirmake" command and the "~/Maildir" argument together in a shell script to see if that solves the problem:
su - MYUSER -c MYSCRIPT_WITH_CMD_AND_ARGS
|
|
|
|
06-08-2004, 11:45 PM
|
#7
|
|
Member
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59
Original Poster
Rep:
|
The reason I don't want to is becasue I do not know shell scripting yet.
Guess I have to learn that to progress.
Thanks for your help.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:48 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|