import subprocess

import os


(rfd, wfd) = os.pipe()

arg = "-d%d" % rfd

try:

    p = subprocess.Popen(["sshpass",arg,"ssh","-l","haohzhang","phxaishdc9dn1447.stratus.phx.ebay.com","ls","/tmp/"], stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE)

    os.close(rfd)

    os.write(wfd,"PASSWORD\n")

    os.close(wfd)

    stdout, stderr = p.communicate()

    print stdout, stderr

except OSError:

    print("to use the 'ssh' connection type with passwords, you must install the sshpass program")