import pexpect
ssh = pexpect.spawn('ssh localhost') #建立新线程,执行"通过ssh连接本地"
ssh.expect('.*password:') #正则匹配输入密码提示,匹配才继续执行
ssh.sendline("123456") #输入密码
ssh.interact() #执行
Created
January 11, 2013 06:11
-
-
Save chzyer/4508354 to your computer and use it in GitHub Desktop.
python命令行预处理实例[ssh远程连接]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment