You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cvm/runhelper/runhelper

27 lines
472 B
Python

#!/usr/bin/python
import json, subprocess
from optparse import OptionParser
parser = OptionParser()
(options, args) = parser.parse_args()
try:
command = args[0]
except IndexError, e:
exit(1)
command = json.loads(command.decode('base64'))
pr = subprocess.Popen(["sudo"] + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
data = pr.communicate()
pr.wait()
obj = {
'stdout': data[0],
'stderr': data[1],
'returncode': pr.returncode
}
print json.dumps(obj)