Perform like a sudo in fabric

I have a command service app start-demo, I need to type sudo service app start-demoin the command line.

I used sudo(service app start-demo)and sudo(sudo service app start-demo)but I still get

Warning: sudo () encountered an error (return code 1) while executing 'sudo service app start-demo'

I have no problem running this as a command line in a terminal.

I'm not sure what SADeprecationWarning:is considered a structure error?

Thank.


user@box:/var/lib/app$ fab kickstart
You are installing prereqs..........
### Install Prereqs for Populate ###
No hosts found. Please specify (single) host string for connection: localhost
[localhost] Login password: 

### I am starting demo ###
[localhost] sudo: sudo service app start-demo
[localhost] out: Starting demo

Fatal error: sudo() encountered an error (return code 1) while executing 'sudo service app start-demo'

Aborting.
Disconnecting from localhost... done.

the code

def pserve():
    print '### I am starting demo ###'
    #with settings(warn_only=True):
    sudo('sudo service app start-demo')
    #sudo('service app start-demo')

or the command sudowill fail.


/etc/sudoers

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults    env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL
+5
source share
1 answer

faq, 0 ( unix ), , .

+3

All Articles