pexpect prompt for blank space in python -


can 1 please tell me, prompt have give expecting blank space python script.i need execute command execute after sees expect prompt.on doing manually got prompt blank space,and has expect same prompt via script also.

import pexpect import pxssh import time import os,re,sys

def ssh(ipaddr,password): try:

    ss = pexpect.spawn(ipaddr)     print ipaddr             ss.logfile = open("/tmp/mynewlog", "a")         print "ssh connecting"         print  except:     print "connection refused"     print     #sys.exit()      try:         print password         ss.expect (':')              ss.sendline (password +"\n")             print "connected"             time.sleep(30)             ss.expect (">")             print "connection established"             print      except:             print "permission denied, please try again."                 print                 sys.exit()     try:         ss.sendline ('taskkill /f /im iperf.exe\n')         time.sleep(30)         ss.expect ('>')             ss.sendline ('cd /d d:\iperf-2.0.5-2-win32\n')             ss.expect ('>')             ss.sendline ('iperf -s\n')#########this command need execute , i'm  expecting blank space prompt             ss.sendline (pexpect.eof)             print "end"             ssh()   

except: print "failed execute command"
print sys.exit()

edit:

ss.expect takes string regular expression, , uses search output program. in case, if want match line before dashes, can do

ss.expect(r'tcp window size: .*yte \(default\)') 

more broadly, i'm not sure you're trying accomplish this, might helpful @ this page.


old:

i'm not sure mean when expect blank space prompt.

1) space? if ss.expect(' ') seems should work.

2) there end of line? if ss.expect('\n') seems should work.

3) iperf give prompt? waiting input? , you're sending eof? kill program?


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -