Start a service as user

Hi
I need a service to be start as user after a reboot. My script in /etc/init.d contain the following:

start()
{
su - $USER
cd ${INSTALL_PATH}/bin
./MyApp -X
exit
return 0
}

This function stops after su - $USER, I get user shell, and only if I manualy exit it continues with the next commands cd .... and MyApp starts as root instead of user.

Thanks,
Bianca

su - user -c "command" ? Can't you do that instead ?

Hi,

Because MyApp gets an argument -X, if I try
su - bianca -c . /home/MyApp -X

I get
su: invalid option -- d
Try `su --help' for more information.

Bianca

why using dot ? The following works for me :

su - testuser -c "perl memusage.pl 21226"

after submitting the password, the memusage.pl script returns what's expected. Maybe the quotes are the solution.

start()
{
su - $USER -c "${INSTALL_PATH}/bin/MyApp -X"
# or
# su - $USER -c "cd ${INSTALL_PATH}/bin/; ./MyApp -X"
return 0
}

Thanks for the solution. The second example works exactly as I need it to.

Have a nice day,
Bianca