#!/usr/bin/env python import sys import subprocess lcmd=['pkexec'] lcmd.extend(sys.argv[1:]) try: subprocess.check_output(['xhost','+SI:localuser:root'],stdin=None,stderr=None) print '{}'.format(subprocess.check_output(lcmd)) subprocess.check_output(['xhost','-SI:localuser:root'],stdin=None,stderr=None) except Exception as e: print e