From: Juan P. F. G. <jfe...@gm...> - 2007-06-12 19:41:28
|
Hello, I'm trying to expect an modem with cu session but i never got answer from the modem . Here is my ugly code my $command = "cu -s 9600 -l ttyS0"; if ($_[5] eq 'ROOT') { print "Iniciando conexion telnet como ROOTEXPECT \n " if ($debug eq "1"); $rootexpect=Expect->spawn($command, @params) or die "$command: $! FALLO\n"; if ($_[9] eq "MODEM") { my $timeout = "8"; $rootexpect->exp_internal('2'); $rootexpect->expect($timeout, "nnected"); $rootexpect->send("\n"); $rootexpect->send("AT\n"); $rootexpect->expect($timeout,"OK"); my $x; $rootexpect->interact($x, 'XXX'); } } Here is the debug output (Looks like modem is not acepting the \n after AT) spawn id(4): Does `\007Connected.\r\n' match: pattern #1: -ex `nnected'? YES!! Before match string: `\007Co' Match string: `nnected' After match string: `.\r\n' Matchlist: () spawn id(4): list of patterns: #1: -ex `OK' spawn id(4): Does `.\r\n' match: pattern #1: -ex `OK'? No. spawn id(4): Does `.\r\n\nAT\n' match: pattern #1: -ex `OK'? No. With the script @ interact mode AT responds fine at OK at OK at OK I connected a cisco router console port instead the modem, and changed the expect commands: $rootexpect->exp_internal('2'); $rootexpect->expect($timeout, "nnected"); $rootexpect->send("\n"); $rootexpect->expect($tiemout, "outer"); $rootexpect->send("ter le 0\n"); $rootexpect->send("sh ver\n"); $rootexpect->expect($timeout,"isco"); my $x; $rootexpect->interact($x, 'XXX'); And the router successfully returns the output of the command 'sh ver'... Any Ideas? Are there better terminals than cu, which can be used to interact with expect-perl? Thanks in advance |