Created
September 1, 2012 22:02
-
-
Save offlinehacker/3588862 to your computer and use it in GitHub Desktop.
Jenkins script console shell client
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/python | |
import re | |
import sys | |
import urllib | |
import urllib2 | |
command=" ".join(sys.argv[1:]) | |
srv="http://IP:8082/script" | |
script="def command = \"\"\""+command+"\"\"\"\ndef proc = command.execute()\nproc.waitFor()\nprintln \"stdout: ${proc.in.text}\"" | |
data= urllib.urlencode({'script': script, 'json':'{"script": "' + script + '", "": "'+script+'"}', 'Submit': 'Run'}) | |
u = urllib2.urlopen(srv, data) | |
lines= u.readlines() | |
a = re.compile(r'<pre>stdout: (.*?)<\/pre>', re.MULTILINE|re.DOTALL) | |
m = a.search(lines) | |
if m: | |
print m.group(1).strip().strip() | |
else: | |
print "command failed" | |
print lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment