Created
August 5, 2016 21:10
-
-
Save douglas-larocca/4173d94676068b2d48a8532a3164b03f to your computer and use it in GitHub Desktop.
fmxdbc_listener.exe restart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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