1

Possible Duplicate:
Running interactive commands in Paramiko

I am very new to Python. I am trying to run a batch file on a remote computer with paramiko:

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("host", username="uname", password="pwd", allow_agent = False)
i, o, e = ssh.exec_command("c://test.bat")
print o.read()

The problem is that the remote batch file at some point is waiting for input (pause) so I am stuck after the read command and nothing prints out.

any suggestions ?

Community
  • 1
  • 1
shaharke
  • 11
  • 1

1 Answers1

0

If paramiko is not a strict requirement, you could consider fabric with fexpect:

from fexpect import expect, expecting, run 

prompts = []
prompts += expect('What is your name?','John')

with expecting(prompts):
    run('c://test.bat')
Jasper van den Bosch
  • 3,169
  • 4
  • 32
  • 55