Run Linux command as predefined user

Posted by vijay.shad on Stack Overflow See other posts from Stack Overflow or by vijay.shad
Published on 2010-03-30T11:29:04Z Indexed on 2010/03/30 11:33 UTC
Read the original article Hit count: 411

Filed under:
|

Hi all,

I have created a shell script to start a server program.

startup.sh  start

When above command will executes, it will try starts the server as adminuser. To achieve this my script has written like this.

SUBIT="su - adminuser -c "
SERVER_BOX_COMMAND_A="Server"

##############
# Function to start cluster

function start(){

   $SUBIT "$SERVER_BOX_COMMAND_A"

}

When i execute the command it asks for password. Is there any other way to do this so, it will not ask for password.

© Stack Overflow or respective owner

Run Linux command as predefined user

Posted by vijay.shad on Super User See other posts from Super User or by vijay.shad
Published on 2010-03-30T11:29:04Z Indexed on 2010/03/30 14:03 UTC
Read the original article Hit count: 411

Filed under:
|

Hi all,

I have created a shell script to start a server program.

startup.sh  start

When above command will executes, it will try starts the server as adminuser. To achieve this my script has written like this.

SUBIT="su - adminuser -c "
SERVER_BOX_COMMAND_A="Server"

##############
# Function to start cluster

function start(){

   $SUBIT "$SERVER_BOX_COMMAND_A"

}

When i execute the command it asks for password. Is there any other way to do this so, it will not ask for password.

I have seen this behavior in Jboss startup script provided on jboss. That script changes the user to jboss and then starts the jboss server. I wanted my script to behave same way.

© Super User or respective owner

Related posts about shell-scripting

Related posts about linux