#!/usr/bin/python import pexpect import pxssh try: remote=pxssh.pxssh() hostname=raw_input('hostname:') username=raw_input('username:') password=raw_input('password:') remote.login(hostname,username,password) remote.sendline('cd /opt/autotest/') remote.prompt() remote.sendline('ll') remote.prompt() print remote.before print('成功了吧') remote.logout() except pxssh.ExceptionPxssh,e: print'pxssh failed on login' print str(e)