0

My ubuntu server is login server by ssh key and user is ubuntu.
and tomcat user is tomcat and it's password is tomcat.
I want to start tomcat by Fabric. and my method is like this, login in user is ubuntu, and want to su user tomcat; but i had a error su: must be run from a terminal
if I remove the pty=False
it will run the startup.sh but will close after fabric finish.

suuser(user='tomcat',pwd='tomcat',command= '/data/tomcat/%s/bin/startup.sh '%port,pty=False)

def suuser(user,pwd,command='',pty=True):

    with settings(password= "%s" % pwd,
        sudo_prefix="su  %s -c " % user,
        sudo_prompt="Password:"):
        sudo(command,pty=pty)
Community
  • 1
  • 1
Reilost
  • 56
  • 2
  • 1
    remove pty=False and put & after startup.sh in command. suuser(user='tomcat',pwd='tomcat',command= '/data/tomcat/%s/bin/startup.sh &'%port) – Avichal Badaya Jun 05 '13 at 18:09
  • remove pty=False and add & it's run the sh but tomcat didn't start , – Reilost Jun 06 '13 at 01:45
  • instead of suuser command use run("su - tomcat & /data/tomcat/{port}/bin/startup.sh") after setting up the env variables for login into the server. – Avichal Badaya Jun 07 '13 at 18:27

1 Answers1

0

Remove pty=False add set -m to command, like this:

command= 'set -m; /data/tomcat/%s/bin/startup.sh '

set -m turns on job control, you can run processes in a separate process group.

Community
  • 1
  • 1
Sagacity
  • 11
  • 3