Can't get a script to run properly with command line parameters when using ' eval su - user1 -c"Hello.sh John" '
Posted on 2011-10-11
PROBLEM: Want to get a sub-process that takes parameters, to run properly when it is called by a parent process, and this parent process is being executed by a different user to the one running the sub-process:
e.g. Script 'Hello.sh' that must be run as user 'user1':
echo "Hello $1"
e.g Script 'm_Script' that is to be run by user 'root'
eval su - user1 -c "Hello.sh John_Browne"
I can't get the above to work properly, 'm_Script' just prints 'Hello', not 'Hello John_Browne''.
 This is just a simple breakdown of what I actually have to do, so please don't tell me I can run everything as user root.
 If there is another approach I can use that would allow me to pass information (parameters) to a sub-process that is to be run by a different user, please tell me how.
 Execution of the main program must wait until the sub-process is finished.