Hi all,<br /><br />Sorry this is so long and vague (I'll try to code up a s=
mall example because my little project uses a back-end database and I'd lik=
e to split the Expect piece out - this will take a while). For anyone who's=
interested have a look at the March 2007 thread to see the solution to my =
original problem.<br /><br />My new code (below) no longer works (I've done=
a lot of code changes and need to backtrack to see what exactly broke it).=
In the meantime I'm wondering if there's a better way.<br /><br />Here's w=
hat I'm trying to do...<br /><br />1. Match and capture a prompt at the sta=
rt of a line.<br /> This works perfectly (March 2007 code)<br /=
>2. Look up the matched prompt and see if it...<br /> (a) needs=
a response,<br /> (b) can be ignored, or,<br /> (c=
) needs special handling..<br /> Always works.<br />3a. For &qu=
ot;normal" prompt send response + "\r" and exp_continue for =
next prompt.<br />3b. For "ignored" prompt just exp_continue.<br =
/>3c. For a "special" prompt sleep 3 seconds then check if there'=
s any more output, if there is the script shouldn't send a response because=
the remote system is showing the status of this setting as opposed to aski=
ng for input. It will then present the next prompt (i.e. treat this prompt =
as in case 3b above). But if there's no further output it's a request for i=
nput and so a response must be given (even if just "\r") as in 3b=
.<br /><br /><br />Case 3c isn't working. When I do it manually I get this.=
..<br /><br />NORMAL_PROMPT_1 (I send response + "\r")<br />NORMA=
L_PROMPT_2 (I send response + "\r")<br />SPECIAL_PROMPT_1 NO (I s=
ee "NO" straight away and do nothing)<br />SPECIAL_PROMPT_2 (I se=
nd response + "\r" as input required)<br />NORMAL_PROMPT_3 (I sen=
d response + "\r")<br />...<br /><br /><br />When scripted this h=
appens...<br /><br />NORMAL_PROMPT_1 (script sends response + "\=
r")<br />NORMAL_PROMPT_2 (script sends response + "\r"=
)<br />SPECIAL_PROMPT_1 (sleep 3 seconds)<br /> &nbs=
p; (don't=
see further output so send response + \r)<br /> &nb=
sp; print=
debug message to terminal "*sending*"<br /> &nb=
sp; =
Then I get NO from the remote printed on the screen<br /><br />So it looks=
like....<br /><br />NORMAL_PROMPT_1 RESPONSE_1\r<br />NORMAL_PROMPT_2 RESP=
ONSE_2\r<br />SPECIAL_PROMPT_1 RESPONSE_3\r *sending*<br />NO (the \r sent =
above forces a newline here even if response is "")<br />NORMAL_P=
ROMPT_3 remote assumes RESPONSE_3 + \r is for this.<br /><br />Wrong :-(<br=
/><br /><br />It seems that after sending "response\r" the accum=
ulator suddenly gets the NO from the remote system but that's after the scr=
ipt thinks it has to send a response. Kermit may be the problem as it's dri=
ving the link (either serial or via telnet) and it may be buffering (I don'=
t think so as it works OK manually)<br /><br /><br />Is there a way to chec=
k if I need to send a response without having to actually send it?<br /><br=
/>I've tried combinations of<br /> buffer =3D exp->after()<br />a=
nd<br /> buffer =3D clear_accum(); set_accum($buffer)<br />but no joy=
.<br /><br />Is there a way to check for further characters without absorbi=
ng them (because that text could be my next prompt and I need to keep that =
in the accumulator for the next pass of expect)<br /><br />Thanks,<br />Joh=
n.<br /><br /><BR>
|