From: <li...@jo...> - 2007-05-08 22:24:43
|
<p>Here's something that worked for me...</p><p>1. Expect on the system pro= mpt ( qr/^REQ: / in my case) then send the command to print the listing</p>= <p>2. Optionally "expect" the command (to absorb it from the list= ing), you can also absorb any headers you don't want. </p><p>3. Now le= t the system do its work.</p><p>4. Expect on another system prompt.</p><p>W= hatever printed in step 3 (i.e. from the system) is stored in $exp->befo= re(), this is your listing.</p><p> </p><p>Example:</p><p># Step 1: Get= the system prompt and send a response...<br />$exp->expect(10,<br />&nb= sp; [ qr/^REQ: / =3D> sub {<br /> &nb= sp; $self =3D shift;<br /> &= nbsp; $self->send("PRINT\r")<br /> &nbs= p; }<br /> ],<br /> [ timeout =3D> sub { die ("Timeout = in step 1") }<br /> ]<br />);<br /><br /># Step 2 not coded</p><= p># Step 3: System prints stuff here</p><p> # Step 4: Find the next sy= stem prompt<br />$exp->expect(10,<br />=0D [ qr/^REQ: / ],<br /> [ timeout =3D> sub { die ("Timeo= ut in step 4") } ]<br />=0D );</p><p>$listing =3D $exp->before();<br />print $listing;</p><p><br />R= egards,<br />John.</p><p> </p><p> </p><BR> |