Skip to content
Tcl Source Code Artifact [fd2580f804]
Login

Artifact [fd2580f804]

Artifact fd2580f80471fcc91f8ceb7b89ddebc066fa252c:

Ticket change [fd2580f804] - Ticket [30c5d37cfa0028c9|30c5d37cfa] <i>Expect eof occurring before end of output from spawned process</i> status still Open with 3 other changes by tld on 2013-08-13 20:22:51.
D 2013-08-13T20:22:51.069
J icomment Oh\sman...makr,\syou\smay\shave\ssaved\sme\sbig\stime\son\sthis\sone.\r\n\r\nI\shad\sread\sall\sthat\sabout\sthe\sfull_buffer\setc.\s\sHere's\swhat\shad\sme\sconfused:\s\sAs\syou\scan\ssee\sin\smy\sexample,\sI\swas\srelying\son\s"log_user\s1"\sto\ssend\sthe\soutput\sof\sthe\sspawned\sprocess.\s\sWhat\sconfused\sme\sabout\swhat\sI'd\sseen\sregarding\sfull_buffer\sis\sthat\sthere\swas\sno\squestion\sthat\swith\slarge\soutput,\sI\swas\slikely\sgetting\sfull\sbuffers\smaybe\shundreds\sof\stimes...however\sthe\stext\swas\sin\sfact\sgetting\soutput\sby\sthe\sscript\sbased\son\slog_user\s1.\s\sApparently\showever,\srelying\son\sthat\sis\sa\smistake,\sas\sit\scan\sget\stripped\sup\sby\sthe\slast\sfull\sbuffer,\sloosing\sthe\send\sof\sthe\soutput.\r\n\r\nI\sjust\stested\sthe\sfollowing\schange:\sa)\sleaving\slog_user\sat\s0,\sb)\sadding\sa\sfull_buffer\sthat\sdoes\s"puts\s-nonewline\s$expect_out(buffer)",\sand\sc)\sadding\sthat\ssame\sputs\sstatement\sto\sthe\seof\sblock\sbefore\sexiting.\s\sAs\sfar\sas\sI\scan\stell\sso\sfar,\sthat\sworks\sperfectly.\r\n\r\nThanks\sso\smuch\sfor\sthat.\s\sWish\sI'd\slooked\sinto\sit\smore\scarefully\sbefore.\s\sHere's\sthe\sworking\stest\sscript:\r\n\r\nset\stimeout\s30\r\n\r\nproc\sexitspawnstat\sargs\s{\r\n\s\s\scatch\swait\sresult\r\n\s\s\sset\srtn\s[lindex\s$result\s2]\r\n\s\s\sif\s{\s!$rtn\s}\s{\r\n\s\s\s\s\s\sset\srtn\s[lindex\s$result\s3]\r\n\s\s\s}\r\n\s\s\sexit\s$rtn\r\n}\r\n\r\nlog_user\s0\r\nset\sstty_init\sraw\r\nspawn\s-noecho\scat\s./in.txt\r\nexpect\s{\r\n\s\s\seof\s{\r\n\s\s\s\s\s\sputs\s-nonewline\s$expect_out(buffer)\r\n\s\s\s\s\s\sexitspawnstat\r\n\s\s\s}\r\n\s\s\sfull_buffer\s{\r\n\s\s\s\s\s\sputs\s-nonewline\s$expect_out(buffer)\r\n\s\s\s\s\s\sexp_continue\r\n\s\s\s}\r\n\s\s\stimeout\s{\r\n\s\s\s\s\s\slog_user\s1\r\n\s\s\s\s\s\ssend_user\s"Timeout.\\n"\r\n\s\s\s\s\s\sexit\s253\r\n\s\s\s}\r\n\s\s\s-nocase\s-re\s"password:"\s{\s\r\n\s\s\s\s\s\sexp_continue\r\n\s\s\s}\r\n\s\s\s"(yes/no)?\s"\s{\s\r\n\s\s\s\s\s\sexp_continue\r\n\s\s\s}\r\n\s\s\s-nocase\s-re\s"Enter\spassphrase"\s{\r\n\s\s\s\s\s\sexp_continue\r\n\s\s\s}\r\n\s\s\s"testing-sudo-passwd:"\s{\r\n\s\s\s\s\s\sexp_continue\r\n\s\s\s}\r\n}
J login tld
J mimetype text/plain
K 30c5d37cfa0028c9ef83fa9efc490f4bc28b64ff
U tld
Z c127c5f601106fbab4f24e548c82af6f