in reply to Re: Net:SSH::Expect and microcom?
in thread Net:SSH::Expect and microcom?

Thanks, but it doesnt work. I am experiencing some very odd behaviour with the suggested snipped.

When run manually, the AT command returns to OK within 500ms. Since the RegEx would match and it still times out, I believe it safe to conclude that it still doesnt pass in the AT command.

More important is the fact that no matter what timeout I set, it throws the warning after ~2 seconds. I've set 50 seconds in the example below:

print "Before timeout: " . localtime() . "\n"; my $timeout = 50; $exp->expect($timeout, [qr/^OK$/ => sub { print "Success!\n"; }], [qr/^ERROR$/ => sub { print "Failure!\n"; }]) or warn "Timeout!"; print "After timeout: " . localtime() . "\n";
and the output I get from the above:
Before timeout: Tue Nov 8 03:31:02 2011 Timeout! at getdbm.pl line 18. After timeout: Tue Nov 8 03:31:04 2011

Am I experiencing a bug here, or am I (still) an idiot?

Replies are listed 'Best First'.
Re^3: Net:SSH::Expect and microcom?
by salva (Canon) on Nov 08, 2011 at 12:13 UTC
    Maybe you have to wait for microcom to settle before sending anything. Try sleeping for 1 second before sending the modem command.

      No luck - it sleeps for 5 seconds an continue - if anything, it made the issue of timeout not being honoured even worse:

      Before timeout: Tue Nov 8 04:14:40 2011 Timeout is: 500 Timeout! at getdbm.pl line 20. After timeout: Tue Nov 8 04:14:40 2011
        opps, you have to use the m switch on the regular expressions in order to make ^ and $ match at the beginning and end of lines:
        $exp->expect($timeout, [qr/^OK$/m => sub { ... }], [qr/^ERROR$/m => sub { ... }]);