From 5b168e498501a02f4478d8e9ffd8a248712eaca1 Mon Sep 17 00:00:00 2001 From: Alex Kaplan Date: Mon, 12 Oct 2015 16:00:27 -0700 Subject: [PATCH] verify script now works if root user has password --- verify.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/verify.sh b/verify.sh index f3db1b2..6d48937 100755 --- a/verify.sh +++ b/verify.sh @@ -6,16 +6,30 @@ import serial import re #------------------------------------------------------------------ -def answer_prompt(sio,prompt_to_wait_for,answer_to_write): +def answer_prompt(sio,prompt_to_wait_for,answer_to_write,send_cr=True): #------------------------------------------------------------------ + sio.flush() prompt_found = False data = '' - while not prompt_found: - data += sio.read(100); + #if send_cr: + #sio.write(unicode('\n')) + + d='something' + while not len(d)==0: + d = sio.read(2000); + data += d + print '-' * 50 + print ' %d bytes read' % (len(data)) + print '-' * 50 + + print data + + while not prompt_found: + d = sio.read(100); + data += d print '-' * 50 print ' %d bytes read' % (len(data)) print '-' * 50 - print data if(data[:-1].endswith(prompt_to_wait_for)): sio.write(unicode(answer_to_write+'\n')) print '-' * 50 @@ -23,8 +37,10 @@ def answer_prompt(sio,prompt_to_wait_for,answer_to_write): print '-' * 50 prompt_found = True else: - sio.write(unicode('\n')) + if send_cr: + sio.write(unicode('\n')) sio.flush() + #sys.stdin.readline() #------------------------------------------------------------------ def scanfor(sio,regexp_to_scan_for,answer_to_write): @@ -64,6 +80,7 @@ def main(): #login answer_prompt(sio,'login:','root') + answer_prompt(sio,'Password:','chip',False) answer_prompt(sio,'#','hwtest') d=scanfor(sio,r'.*### [^#]+ ###.*','poweroff')