Skip to content

Instantly share code, notes, and snippets.

@douglas-larocca
Created August 5, 2016 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglas-larocca/4173d94676068b2d48a8532a3164b03f to your computer and use it in GitHub Desktop.
Save douglas-larocca/4173d94676068b2d48a8532a3164b03f to your computer and use it in GitHub Desktop.
fmxdbc_listener.exe restart
#!/usr/bin/env python3
import sys
from winrm.protocol import Protocol
def xdbc_restart(host, user, password):
p = Protocol(
endpoint=('https://%s:5986/wsman' % host),
transport='ntlm',
username=user,
password=password,
server_cert_validation='ignore'
)
shell_id = p.open_shell()
command_id = p.run_command(shell_id, 'fmsadmin', ['restart', 'xdbc', '-y'])
std_out, std_err, status_code = p.get_command_output(shell_id, command_id)
p.cleanup_command(shell_id, command_id)
p.close_shell(shell_id)
return std_out.decode('utf-8'), std_err.decode('utf-8'), status_code
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='fmxdbc_listener.exe restarter')
parser.add_argument('-u', '--user', dest='user', help='[DOMAIN\]USERNAME')
parser.add_argument('-p', '--password', dest='password', help='password')
parser.add_argument('-h', '--host', dest='host', help='FMServer hostname or IP')
options = parser.parse_args()
sys.stdout.write('Restarting xDBC... ')
print(*xdbc_restart(options.host, options.user, options.password))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment