Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Unix&Linux>>su $USER -c $COMMAND fails with exit code 1

su $USER -c $COMMAND fails with exit code 1

dpr
04-08-2006, 10:59 AM
Greetings,

I'd like to execute a process with an UID of a different user, e.g.


[nostromo:~] root# su fetchmail -c id


What I expect as output would be


uid=102(fetchmail) gid=4294967295(nogroup)


but what I get is no output but an exit code 1. I'm afraid this is related to netinfo, which is a totally new thing for me.

Does anyone of you know how I could invoke commands as a specified user?

Thanks in advance,
Denny

hayne
04-08-2006, 12:41 PM
I suspect that the user account that you are trying to 'su' to does not have a shell. This is nothing particularly new to netinfo - it would also happen with a classical /etc/passwd account that was configured to have no shell.
From 'man su':

su requests the password for login and switches to that user and group ID after obtaining proper authentication. A shell is then executed, and any additional shell arguments after the login name are passed to the shell.

Try it with a user account that can login - e.g. one of the accounts that a human uses. You should find that it works fine - it does for me (on 10.4.6)

You can see the configuration of all user accounts with the following command:

nidump passwd /

dpr
04-09-2006, 03:24 PM
I suspect that the user account that you are trying to 'su' to does not have a shell.

You are right. After changing 'false' to 'bash' su is now working as expected. This seems to be one of the differences between Mac OS and Linux...

Thanks for your help,
Denny


 

TOP

Windows Server Outsell
Unix Signals And C++ E

For more info

Unix Signals And C++ E
Windows Server Outsell
bash not using my .bas
Applescript: Hide Proc
help with installing p
Mozilla install from d
ssh - don't want to us
Escaping quotes in Tig
Terminal Keybindings 
JAVA help, please! 

News Archive

Displaying Images on t
Install Office from th
Terminal Problem...? 
cc1plus not executable
desktop icons.. 
at & growlnotify 
unknown terminal type 
scp arbitrary files 
What and why is a 'Dis
permissions already me

Related stories:

What and why is a 'Disk Image"?
permissions already messed up!!
Lost 8 GB of HD space?
Linux On My Mac
Scary message
Sound
Command line to change icon

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics