Trying to convert this bash line to Python 2.6

29 views Asked by At

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.

0

There are 0 answers