Skip to content

Instantly share code, notes, and snippets.

@xlcommunity
Created April 10, 2015 15:48
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 xlcommunity/7f5faa53d7dbfecd3bbb to your computer and use it in GitHub Desktop.
Save xlcommunity/7f5faa53d7dbfecd3bbb to your computer and use it in GitHub Desktop.
RemoteScript.py
# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS.
from __future__ import with_statement
from overtherepy import OverthereHostSession, SshConnectionOptions, OverthereHost, StringUtils
import sys
host = OverthereHost(SshConnectionOptions(hostAddress, username, privateKey=privateKey))
#logging must be turned of for use in XLR
session = OverthereHostSession(host, enable_logging=False)
with session:
remote_script = session.upload_text_content_to_work_dir(script, "script%s" % session.os.scriptExtension, executable=True)
response = session.execute([remote_script.path], check_success=False)
output = StringUtils.concat(response.stdout)
err = StringUtils.concat(response.stderr)
if response.rc == 0:
print output
else:
print "Exit code "
print response.rc
print
print "#### Output:"
print output
print "#### Error stream:"
print err
print
print "----"
sys.exit(response.rc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment