Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
<< UPDATED WITH SIMPLER TEST CASE - SAME BEHAVIOUR >> I have an reasonably complex Perl program which is using Perl Expect - part of it is sending initialization information to a modem bank and its doing this sending information slowly using send_slow. The thing is its expecting on it before its finished sending what is there and i cannot work out whats causing it to stop sending. It should be sending AT &F X3 S38=0 \N2 but it always jumps out when it gets to the = sign The part of the program that sends it looks like this
#!/usr/bin/perl -w use strict; use Expect; use Data::Dumper; my $timeout = '20'; my $user_ts = '192.10.1.1 8000'; my $user_ts_user = 'username'; my $user_ts_pass = 'password'; my $exp; $exp = Expect->spawn("telnet $user_ts") or die "Cannot spawn teln +et: $!\n"; my $spawn_ok; $exp->raw_pty(0); $exp->exp_internal(0); $exp->slave->stty(qw(-a)); #$exp->slave->stty(qw(raw -echo)); #$exp->slave->clone_winsize_from(\*STDIN); do_exp ($timeout, 'login', "$user_ts_user\r",0); do_exp ($timeout, "password:", "$user_ts_pass\r",0); do_exp ($timeout, 'Connected to line', "AT &F X3 S38=0 \\N2\r",1) +; $exp->interact(); sub do_exp { my ($_timeout, $_lookfor, $_send,$_slow) = @_; if (my $out = $exp->expect($_timeout,'-re',$_lookfor +)) { print "out=".$out."\n"; if ($_slow == 0){ $exp->send("$_send"); } else { print "Send_SLOW\n"; my @SlowChars = split(//,$_send); print Dumper(@SlowChars); my $return = $exp->send_slow(1,@SlowChars); print Dumper($return); } } else { print Dumper($exp); die "Timeout waiting for $_lookfor.\n"; } }
The logfile output looks like:-
spawn id(4): Does `: *********\n\r\n\r0460127 Connected to line MODEM: +4O at 115200 8N1\n\r\n\r' match: pattern #1: -re `Connected to line'? YES!! Before match string: `: *********\n\r\n\r0460127 ' Match string: `Connected to line' After match string: ` MODEM:4O at 115200 8N1\n\r\n\r' Matchlist: () Printed character 'A' to spawn id(4). Printed character 'T' to spawn id(4). AReceived 'T' from spawn id(4) Printed character ' ' to spawn id(4). TReceived ' ' from spawn id(4) Printed character '&' to spawn id(4). Received '&' from spawn id(4) Printed character 'F' to spawn id(4). &Received 'F' from spawn id(4) Printed character ' ' to spawn id(4). FReceived ' ' from spawn id(4) Printed character 'X' to spawn id(4). Received 'X' from spawn id(4) Printed character '3' to spawn id(4). XReceived '3' from spawn id(4) Printed character ' ' to spawn id(4). 3Received ' ' from spawn id(4) Printed character 'S' to spawn id(4). Received 'S' from spawn id(4) Printed character '3' to spawn id(4). SReceived '3' from spawn id(4) Printed character '8' to spawn id(4). 3Received '8' from spawn id(4) Printed character '=' to spawn id(4). 8Received '=' from spawn id(4) Starting EXPECT pattern matching...
I can connect to the modem bank manually and type the whole string in no issue. I'm bemused - any assistance gratefully appreciated Kicks out of the send slow on 0 in S38=0 Simon

In reply to Perl Expect Send Slow Oddness by setuk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found