I need help converting this bash line to Python 2.6:
# Bash line ssh -X ${var} users |tr ' ' '\n' |uniq |tr '\n' ' ' The output of this command will go to a variable as a string. So far, this is what I have in Python 2.6:
# Python implementation string = subprocess.call("ssh -X {0} users |tr \' \' \'\n\' |uniq |tr \'\n\' \' \'".format(var), shell=True) Is this correct, or is there a better way to do this? Thank you.
-X? You're not doing anything that uses X11.subprocess.call()doesn't return a string at all! But you can switch tocheck_output()if you upgrade to 2.7, or reimplement it using the (clumsy but well documented)Popen+communicate()sequence.