From: Blackstone, J. D. <jda...@ci...> - 2002-07-31 20:26:04
|
I don't think you're supposed to use pids with -i; I think you're supposed to use the Expect object itself. Otherwise, how would it get the object to expect on? jdb -----Original Message----- From: Heidi Ng [mailto:ng_...@ya...] Sent: Wednesday, July 31, 2002 3:11 PM To: exp...@li... Subject: [Expectperl-discuss] using multiple expect objects Hi, I am trying to write a script program which spawns and uses multiple Expect session. I tried using the '-i' option with the Expect object's PID but it gave me the following error message. I got the pid by using $pid = $session->pid() and this returned an integer '1088; to me. Can someone please help me? Thanx! Heidi Can't use string ("1088") as a symbol ref while "strict refs" in use at /usr/lib /perl5/5.6.1/Expect.pm line 564. sub expMatch { my ($session, $pid, $send_arg, $expect_arg) = @_; print $session "$send_arg\r" $temp = $session->expect( $timeout, '-i', [$pid], ['-re', $expect_arg], ['timeout', sub {print "TIMEOUT expecting $expect_arg\n"}] ); } Do You Yahoo!? Yahoo! Health - Feel better, live better |
From: Austin S. <te...@of...> - 2002-07-31 20:41:07
|
On Wed, Jul 31, 2002 at 03:26:00PM -0500, Blackstone, J. David wrote: > I don't think you're supposed to use pids with -i; I think you're supposed > to use the Expect object itself. Otherwise, how would it get the object to > expect on? > That's right. I think the docs are clear on that point, but they seem a little vague that expect isn't supposed to be called as an object method: $object->expect($timeout, @match_patterns) or, more like Tcl/Expect, expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); which might imply something like $object->expect($timeout, '-i'...). Perhaps it would be clearer to have: Expect::expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); Austin |
From: Heidi Ng <ng_...@ya...> - 2002-07-31 21:21:12
|
I tired using the Expect object as suppose to the object's pid. However, it didn't work, so that's why I tried using the pid. The thing I was trying to do was: 1) created an Expect object...did some print's and expect's 2) the script went off to do something else. 3) wanted to talk to the expect object created previously but couldn't. Let me try it with using the object again. Thanks! Heidi Austin Schutz <te...@of...> wrote: On Wed, Jul 31, 2002 at 03:26:00PM -0500, Blackstone, J. David wrote: > I don't think you're supposed to use pids with -i; I think you're supposed > to use the Expect object itself. Otherwise, how would it get the object to > expect on? > That's right. I think the docs are clear on that point, but they seem a little vague that expect isn't supposed to be called as an object method: $object->expect($timeout, @match_patterns) or, more like Tcl/Expect, expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); which might imply something like $object->expect($timeout, '-i'...). Perhaps it would be clearer to have: Expect::expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); Austin --------------------------------- Do You Yahoo!? Yahoo! Health - Feel better, live better |
From: Heidi Ng <ng_...@ya...> - 2002-07-31 21:49:01
|
I double checked my script and tried using the expcet object. The following are 2 cases I tried. The first one is one without '-i'. When using this method, everything works fine. I turned on exp_internal and saw that expect actually sent and got a match. However, when I used the 2nd method with the '-i', the match field is blank. ($expect_arg: OK, $timeout: 120) 1) $temp = $session->expect( $timeout, ['-re', $expect_arg], ['timeout', sub {print "TIMEOUT expecting $expect_arg\n"}]); 2) $temp = $session->expect( $timeout, '-i', [$session], ['-re', $expect_arg], ['timeout', sub {print "TIMEOUT expecting $expect_arg\n"}] ); ------------------------------------------------------------------------------------------------------------------ Here's the exp_internal for the 1) and 2) case.... is my syntax wrong? ------------------------------------------------------------------------------------------------------------------ Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0xa863a8c)', 120, 'ARRAY(0xa869b58)', 'ARRAY (0xa86ec50)') called at VQT_utils.pl line 196 main::expMatch('Expect=GLOB(0xa863a8c)', 1008, 'reset', 'OK') called at VQT_abacus.pl line 141 main::abacusReset('Expect=GLOB(0xa863a8c)', 1008) called at VQT_abacus.p l line 264 main::abacusRun('Expect=GLOB(0xa863a8c)', 1008, 'C:\\Abacus5.11\\BIN', ' reset n id(6): Does ` \033[13;1H\033[0m spawn id(6): Does ` \033[13;1H\033[0m OK spawn id(6): Does ` \033[13;1H\033[0m \ 033[13;1H\033[0mreset\r\033[13;1H\033[0mr \033[13;1H\033[0mre \033[13;1H\033[0mres \033[1 3;1H\033[0mrese \033[13;5H\033[0m\033[13;1H\033[0mreset \033[14;1H\033[0m \033[14;1H\033[0m\ 033[14;1H\033[0mOK \033[15;1H\033[0m ' match: pattern #1: -re `OK'? YES!! Before match string: ` \033[13;1H\ 033[0m \033[13;1H\033[0mreset\r\033[13;1H\033[0mr \033[13;1H\033[0mre \033[13;1H\033[0 mres \033[13;1H\033[0mrese \033[13;5H\033[0m\033[13;1H\033[0mreset \033[14;1H\033[0m \033[14;1H\ 033[0m\033[14;1H\033[0m' Match string: `OK' After match string: ` \033[15;1H\033[0m ===================================================================================== Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0xa863a98)', 120, '-i', 'ARRAY(0xa869b64)', 'ARRAY(0xa869a50)', 'ARRAY(0xa869ad4)') called at VQT_utils.pl line 200 main::expMatch('Expect=GLOB(0xa863a98)', 884, 'reset', 'OK') called at V QT_abacus.pl line 141 main::abacusReset('Expect=GLOB(0xa863a98)', 884) called at VQT_abacus.pl line 264 main::abacusRun('Expect=GLOB(0xa863a98)', 884, 'C:\\Abacus5.11\\BIN', 'C :\DATA\VQT\Test_Results\1028151574', 'VQT_SIP_basic_short.env', 60, 1, 'SIP.phn' reset main::VQT_run(1) called at vqt_main.pl line 54 OK spawn id(6): Does ` \033[13;1H\033[0m \ 033[13;1H\033[0mreset\r\033[13;1H\033[0mr \033[13;1H\033[0mre \033[13;1H\033[0mres \033[1 3;1H\033[0mrese \033[13;5H\033[0m\033[13;1H\033[0mreset \033[14;1H\033[0m \033[14;1H\033[0m\ 033[14;1H\033[0mOK \033[15;1H\033[0m \033[15;1H\033[0m' match: ===================================================================================== ' Austin Schutz <te...@of...> wrote: On Wed, Jul 31, 2002 at 03:26:00PM -0500, Blackstone, J. David wrote: > I don't think you're supposed to use pids with -i; I think you're supposed > to use the Expect object itself. Otherwise, how would it get the object to > expect on? > That's right. I think the docs are clear on that point, but they seem a little vague that expect isn't supposed to be called as an object method: $object->expect($timeout, @match_patterns) or, more like Tcl/Expect, expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); which might imply something like $object->expect($timeout, '-i'...). Perhaps it would be clearer to have: Expect::expect($timeout, '-i', [ $obj1, $obj2, ... ], [ $re_pattern, sub { ...; exp_continue; }, @subparms, [ 'eof', sub { ... } ], [ 'timeout', sub { ... }, \$subparm1 ], '-i', [ $objn, ...], '-ex', $exact_pattern, sub { ... }, $exact_pattern, sub { ...; exp_continue_timeout; }, '-re', $re_pattern, sub { ... }, '-i', \@object_list, @pattern_list, ...); Austin --------------------------------- Do You Yahoo!? Yahoo! Health - Feel better, live better |
From: Roland G. <RGi...@cp...> - 2002-08-04 10:08:24
|
> I double checked my script and tried using the expcet object. The > following are 2 cases I tried. The first one is one without '-i'. > When using this method, everything works fine. I turned on > exp_internal and saw that expect actually sent and got a match. > However, when I used the 2nd method with the '-i', the match field is > blank. ($expect_arg: OK, $timeout: 120) > > 1) $temp = $session->expect( $timeout, ['-re', $expect_arg], > ['timeout', sub {print "TIMEOUT > expecting $expect_arg\n"}]); > > > 2) $temp = $session->expect( $timeout, > '-i', [$session], > ['-re', > $expect_arg], > ['timeout', sub {print > "TIMEOUT expecting $expect_arg\n"}] > ); Try 2) as $temp = expect($timeout, '-i', ...) without the object tagged onto the front. Should work then... Also, set $Expect::Debug = 1 to get further internal information on how Expect handles your call... Hope this helps, Roland -- RGi...@cp... |