Trying to execute commands for different Unix user with that user's environment variable context without fully switching as that user using sudo && su capabilities.
Hoping this would help with security and not having to waste time switching between 10 different app users on same server.
I do not understand why 'ls' command would not get executed, but 'ls -l' would from below output!?..
Does anyone know why?
( Using solaris8, ksh Version: M-11/16/88 )
/home/userA>sudo -l
(root) /usr/bin/su - userB *
/home/userA>sudo /usr/bin/su - userB '/bin/ls'
ksh: ls: cannot execute
# double quotes do not make any difference
/home/userA>sudo /usr/bin/su - userB "/bin/ls"
ksh: /bin/ls: cannot execute
# Here " -c " option makes this work !
/home/userA>sudo /usr/bin/su - userB -c '/bin/ls'
folderA folderB fileA fileB ...
# giving command options make this work.. why?
/home/userA>sudo /usr/bin/su - userA '/bin/ls -l'
drwxr-x--x 8 userB groupX 8192 Jan 1 00:20 BKUP
..........
[SIZE=3][FONT=Bodoni MT][SIZE=3][FONT=Bodoni MT][SIZE=3][FONT=Bodoni MT][SIZE=3][FONT=Bodoni MT][SIZE=3][FONT=Bodoni MT]Please explain what difference does "-c" really make?
I am able to execute commands as a sudo userB and his env variables(.profile, .login etc) without "-c" option as well.