python pexpect failing for curl output -
i capturing curl output after spawning remote machine. expect function keeps getting timed out , tried different patterns still no luck. curl request of form ,
hdl2.sendline("curl -v http://{0}/index.html -o /dev/null".format(host1))
the output received
" > /index.html http/1.1 > user-agent: curl/7.35.0 > host: 13.126.208.1 > accept: */* < http/1.1 200 ok < date: sun, 20 aug 2017 12:32:54 gmt * server apache/2.4.7 (ubuntu) not blacklisted < server: apache/2.4.7 (ubuntu) < last-modified: sun, 20 aug 2017 09:56:44 gmt < etag: "2cf6-5572c61363668" < accept-ranges: bytes < content-length: 11510 < vary: accept-encoding < content-type: text/html < { [data not shown] 100 11510 100 11510 0 0 3055k 0 --:--:-- --:--:-- --:--:-- 3746k * connection #0 host 13.126.208.1 left intact ubuntu@ip-172-31-28-48:~$ "
this end output , have given expect as
hdl2.expect("\$ ")
but every time pexpect timeout. suggestions appreciated.
this may happen because of line buffering: ubuntu@ip-172-31-28-48:~$
not terminated \n
, except
may not consider line. can try this:
hdl2.sendline("curl -v http://{0}/index.html -o /dev/null; echo done".format(host1)) hdl2.expect("done")
(use string unique data instead of done
.)
Comments
Post a Comment