Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want a script X.sh to switch users and perform an action, but so far I have this:

 #!/bin/sh

 sudo su partner -s /bin/bash 
 supervisord -c ~/supervisord.conf
exit

I want that the user partner execute supervisord and exit, but all I get is a switched user in the comand line a bash shell, doing the su partner -s /bin/bash is the only way in which I can access the partner user.

Please Help

share|improve this question
    
sudo su partner -c supervisord? –  Rmano Apr 16 at 22:39
    
Sorry I forgot my .conf file, I tried that way and it did not work, I'll edit my question –  ocespedes Apr 16 at 22:51
    
@Rmano Had the right idea. sudo su partner -s /bin/bash -c 'supervisord -c ~/supervisord.conf' That is assuming ~/supervisord.conf is in fact in the partner user's home directory. –  Petey T Apr 16 at 22:53

1 Answer 1

up vote 5 down vote accepted

You should use sudo -u partner supervisord -C ~/supervisord.conf instead, and set up your current user in the /etc/sudoers file. An entry to allow user "current" to execute this command as "partner" would look something like this:

current ALL=(partner:partner) NOPASSWD: /path/to/supervisord

Make sure and use visudo instead of trying to edit the sudoers file manually. There is a more in-depth but simple explanation of the sudoers file syntax here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.