You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
(26) |
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(5) |
Feb
(3) |
Mar
(11) |
Apr
(10) |
May
(2) |
Jun
(5) |
Jul
(13) |
Aug
(2) |
Sep
(3) |
Oct
(10) |
Nov
(18) |
Dec
(29) |
2002 |
Jan
(12) |
Feb
(14) |
Mar
(73) |
Apr
(28) |
May
(21) |
Jun
(39) |
Jul
(40) |
Aug
(42) |
Sep
(20) |
Oct
(4) |
Nov
(9) |
Dec
(18) |
2003 |
Jan
(2) |
Feb
(8) |
Mar
(6) |
Apr
(24) |
May
(24) |
Jun
(14) |
Jul
(16) |
Aug
(36) |
Sep
(34) |
Oct
(23) |
Nov
(4) |
Dec
(15) |
2004 |
Jan
(6) |
Feb
(13) |
Mar
(7) |
Apr
(5) |
May
(11) |
Jun
(5) |
Jul
(4) |
Aug
|
Sep
(2) |
Oct
(16) |
Nov
(4) |
Dec
(9) |
2005 |
Jan
(2) |
Feb
(1) |
Mar
(3) |
Apr
(10) |
May
(5) |
Jun
(13) |
Jul
(3) |
Aug
|
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(9) |
2006 |
Jan
|
Feb
(10) |
Mar
(22) |
Apr
(14) |
May
(5) |
Jun
(4) |
Jul
(19) |
Aug
(7) |
Sep
(16) |
Oct
(4) |
Nov
(1) |
Dec
(16) |
2007 |
Jan
(17) |
Feb
|
Mar
(35) |
Apr
(5) |
May
(20) |
Jun
(11) |
Jul
(33) |
Aug
(3) |
Sep
(2) |
Oct
(11) |
Nov
(23) |
Dec
(5) |
2008 |
Jan
(10) |
Feb
(9) |
Mar
|
Apr
(6) |
May
(8) |
Jun
(7) |
Jul
|
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(20) |
2009 |
Jan
(8) |
Feb
(8) |
Mar
(3) |
Apr
(8) |
May
(2) |
Jun
(11) |
Jul
(2) |
Aug
|
Sep
(3) |
Oct
(1) |
Nov
(7) |
Dec
(4) |
2010 |
Jan
(2) |
Feb
(1) |
Mar
(3) |
Apr
|
May
(2) |
Jun
(2) |
Jul
(7) |
Aug
(3) |
Sep
(7) |
Oct
(2) |
Nov
(1) |
Dec
(4) |
2011 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(2) |
Jun
|
Jul
(6) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(7) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
(30) |
Apr
(10) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(12) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: Matt Z. <mzagrabe@d.umn.edu> - 2010-08-19 20:39:29
|
On Mon, Aug 9, 2010 at 12:47 PM, James Gaynor <jam...@gm...> wrote: > I am experienced with Expect although I haven't used it for a few years and > am an advanced-novice with Perl. I am looking for some examples of using > the Expect module with Net::Telnet as i am unable to glean inough > information from the perldoc Expect. If someone could spare a sample script > or examples I would be much appreciative. FWIW, I used to use Expect with Net::Telnet because I was under the impression that it would be thread safe, which it might have been. However, there pattern matching issues that arose. For my work, because I make heavy use of threads, I've migrated to Net::Telnet solely. The pattern matching is a bit more kludgy than Expect, but it gets the job done and has been very solid for me. -matt zagrabelny |
From: James G. <jam...@gm...> - 2010-08-09 17:47:09
|
I am experienced with Expect although I haven't used it for a few years and am an advanced-novice with Perl. I am looking for some examples of using the Expect module with Net::Telnet as i am unable to glean inough information from the perldoc Expect. If someone could spare a sample script or examples I would be much appreciative. Thank You |
From: Jonathan <jws...@gm...> - 2010-07-22 09:31:07
|
So it appears this is a Windows Cygwin problem only, trying to send a password to a windows exe. All tests run successfully on linux and mac. I have a feelings it has to do something with some way a windows shell takes in passwords. I have a "temp" workaround for windows using the Win32::GuiTest library to send key strokes to the shell. The support is well appreciated for the feedback received. If anyone has any insight into the problem for windows password prompts, I would be interested in the feedback. Thanks, Jonathan On Wed, Jul 21, 2010 at 4:07 PM, Jonathan <jws...@gm...> wrote: > I had some requests for and to try; much appreciated. Here is the > feedback: > > 1. Expect opening code: > > sub new > { > my $class = shift; > my $exp=Expect->new; > my $spawn_ok = 1; > > #$exp->raw_pty(1); > #$exp->debug($vars{"debug"}); > $exp->log_stdout(1); > $exp->spawn("$AnyConnectShellWrapper::Shell_Path") or die "Cannot > spawn vpn shell $AnyConnectShellWrapper::Shell_Path : $!\n"; > > > my $self = { > > exp => $exp > > }; > > $exp->expect(15, > [ > 'VPN>', > sub { > $spawn_ok = 1; > my $fh = shift; > > } > ], > > [ > eof => > sub { > if ($spawn_ok) { > > die "ERROR: premature EOF in vpn shell.\n"; > } else { > die "ERROR: could not spawn vpn shell.\n"; > } > } > ], > [ > timeout => > sub { > die "No login.\n"; > } > ] > ); > > > bless $self, $class; > return $self; > > } > > > sub connect { > > if ($vars{"debug"}){ > print "Entering AnyConnectShellWrapper::connect\n"; > > } > > my ($self, $hostname, $username, $password, $group) = @_; > my $exp = $self->{exp}; > my $connected = 0; > my $processed = 0; > > if ($vars{"debug"}){ > > print "Username is $username\n"; > print "Password is $password\n"; > print "Group is $group\n"; > print "Hostname is $hostname\n"; > } > > > #Make sure VPN is not already up > if ($self->connected){ > return $connected; > } > > $exp->send("connect $hostname\r"); > $exp->expect(15, > [ > '-re','failed', > > sub { > if ($vars{"debug"}){ > > my $fh = shift; > > $connected = -1; > print "AnyConnectShellWrapper::connect fatal login > error, must destory shell\n"; > > $self->destroy; > > } > } > ], > [ > '-re','error', > > sub { > if ($vars{"debug"}){ > > my $fh = shift; > > $connected = -1; > print "AnyConnectShellWrapper::connect fatal shell > error, must destory shell\n"; > > $self->destroy; > > } > } > ], > [ > '-re','Username:\s*(.*)', > sub { > my $fh = shift; > $fh->send("$username\r"); > exp_continue; > } > ], > [ > '-re','Password:\s', > sub { > my $fh = shift; > sleep 2; > #This is jacked, we have to fix this, will not send > password correct > send_password($fh, $password); > #$fh ->send("$password\r"); > exp_continue; > } > ], > [ > '-re','state:.*Connected', > > sub { > my $fh = shift; > $connected = 1; > if ($vars{"debug"}){ > print "AnyConnectShellWrapper::connect successful > connect\n"; > > } > > } > ], > [ > '-re','VPN>$', > sub { > my $fh = shift; > exp_continue; > } > > ], > [ > eof => > sub { > die "ERROR: premature EOF in vpn shell.\n"; > } > ], > [ > timeout => > sub { > die "No prompt.\n"; > } > ] > ); > if ($vars{"debug"}){ > print "Exiting AnyConnectShellWrapper::connect with return code of > $connected\n"; > } > > return $connected; > > } > > > > > 2. Had some comments on my regular expressions, you guys are right. I > should not be checking for Password:\s*, this wsa in there due to > frustrations of trying to figure out why the password was not being > accepted. Added back proper reg expression > > 3. Tried a recommendation to sleep to allow the application to prepare for > password acceptance. See code. > > Thanks again, > Jonathan > > > > > > > > On Wed, Jul 21, 2010 at 09:39:50AM -0400, Jonathan wrote: > >> I have an application, a client module that control a server module, > >> that my group is automating tests for. This may be a cygwin problem, > >> I will have to try on a cross platform system as the server/client > >> model runs on Windows/Linux/Mac. However, does anyone have any > >> insight into why I can't send a password to this application with > >> cygwin. > >> > >> Output: > >> VPN> connect as5505-1.testbed > >> >> contacting host as5505-1.testbed.cisco.com) for login > information... > >> >> notice: Contactingas5505-1.testbed > >> VPN> > >> >> Please enter your username and password. > >> Group: SSLVPNClient > >> > >> Username: [userA] userA > >> Password: test123 ************************* this is the > >> password, it picked up the password prompt but never is accepted.... I > >> can enter keystroke right when displaying as test123 and it will > >> connect. > >> No prompt. > >> > >> > >> Code: > >> > >> sub connect { > >> > >> if ($VpnHelper::Debug){ > >> print "Entering VpnHelper::connect\n"; > >> } > >> > >> my ($self, $hostname, $username, $password, $group) = @_; > >> my $exp = $self->{exp}; > >> my $connected = 0; > >> > >> if ($VpnHelper::Debug){ > >> print "Username is $username\n"; > >> print "Password is $password\n"; > >> print "Group is $group\n"; > >> print "Hostname is $hostname\n"; > >> } > >> > >> > >> #Make sure VPN is not already up > >> if ($self->connected){ > >> return $connected; > >> } > >> > >> $exp->send("connect $hostname\r"); > >> $exp->expect(15, > >> [ > >> '-re','Username:\s*(.*)', > >> sub { > >> my $fh = shift; > >> $fh->send("$username\r"); > >> exp_continue; > >> } > >> ], > >> [ > >> '-re','Password:\s*', > >> sub { > >> my $fh = shift; > >> $fh ->send("$password\r"); > >> exp_continue; > >> } > >> ], > >> [ > >> '-re','state:\sConnected', > >> sub { > >> my $fh = shift; > >> $connected = 1; > >> exp_continue; > >> } > >> ], > >> [ > >> '-re','VPN>', > >> sub { > >> my $fh = shift; > >> exp_continue; > >> } > >> > >> ], > >> > >> [ > >> eof => > >> sub { > >> die "ERROR: premature EOF in vpn shell.\n"; > >> } > >> ], > >> [ > >> timeout => > >> sub { > >> die "No prompt.\n"; > >> } > >> ] > >> ); > >> > >> } > >> > >> Thank you in advance, > >> Jonathan > >> > >> > ------------------------------------------------------------------------------ > >> This SF.net email is sponsored by Sprint > >> What will you do first with EVO, the first 4G phone? > >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > >> _______________________________________________ > >> Expectperl-discuss mailing list > >> Exp...@li... > >> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > > > -- > > http://singinst.org/ : Our last, best hope for a fantastic future. > > Lojban (http://www.lojban.org/): The language in which "this parrot > > is dead" is "ti poi spitaki cu morsi", but "this sentence is false" > > is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ > > > > |
From: Robin L. P. <rlp...@di...> - 2010-07-21 23:19:12
|
On Wed, Jul 21, 2010 at 04:07:17PM -0400, Jonathan wrote: > I had some requests for and to try; much appreciated. Here is the feedback: > > 1. Expect opening code: > > sub new > { > my $class = shift; > my $exp=Expect->new; > my $spawn_ok = 1; > > #$exp->raw_pty(1); If you didn't already, certainly try uncommenting that. -Robin |
From: Robin L. P. <rlp...@di...> - 2010-07-21 20:17:45
|
On Wed, Jul 21, 2010 at 04:07:17PM -0400, Jonathan wrote: > I had some requests for and to try; much appreciated. Here is the feedback: > > 1. Expect opening code: > > sub new > { > my $class = shift; > my $exp=Expect->new; > my $spawn_ok = 1; > > #$exp->raw_pty(1); > #$exp->debug($vars{"debug"}); > $exp->log_stdout(1); > $exp->spawn("$AnyConnectShellWrapper::Shell_Path") or die "Cannot spawn > vpn shell $AnyConnectShellWrapper::Shell_Path : $!\n"; Since I have no idea how this creates a terminal or how it connects to it, I'm afraid that doesn't really help. -Robin |
From: Jonathan <jws...@gm...> - 2010-07-21 20:07:26
|
I had some requests for and to try; much appreciated. Here is the feedback: 1. Expect opening code: sub new { my $class = shift; my $exp=Expect->new; my $spawn_ok = 1; #$exp->raw_pty(1); #$exp->debug($vars{"debug"}); $exp->log_stdout(1); $exp->spawn("$AnyConnectShellWrapper::Shell_Path") or die "Cannot spawn vpn shell $AnyConnectShellWrapper::Shell_Path : $!\n"; my $self = { exp => $exp }; $exp->expect(15, [ 'VPN>', sub { $spawn_ok = 1; my $fh = shift; } ], [ eof => sub { if ($spawn_ok) { die "ERROR: premature EOF in vpn shell.\n"; } else { die "ERROR: could not spawn vpn shell.\n"; } } ], [ timeout => sub { die "No login.\n"; } ] ); bless $self, $class; return $self; } sub connect { if ($vars{"debug"}){ print "Entering AnyConnectShellWrapper::connect\n"; } my ($self, $hostname, $username, $password, $group) = @_; my $exp = $self->{exp}; my $connected = 0; my $processed = 0; if ($vars{"debug"}){ print "Username is $username\n"; print "Password is $password\n"; print "Group is $group\n"; print "Hostname is $hostname\n"; } #Make sure VPN is not already up if ($self->connected){ return $connected; } $exp->send("connect $hostname\r"); $exp->expect(15, [ '-re','failed', sub { if ($vars{"debug"}){ my $fh = shift; $connected = -1; print "AnyConnectShellWrapper::connect fatal login error, must destory shell\n"; $self->destroy; } } ], [ '-re','error', sub { if ($vars{"debug"}){ my $fh = shift; $connected = -1; print "AnyConnectShellWrapper::connect fatal shell error, must destory shell\n"; $self->destroy; } } ], [ '-re','Username:\s*(.*)', sub { my $fh = shift; $fh->send("$username\r"); exp_continue; } ], [ '-re','Password:\s', sub { my $fh = shift; sleep 2; #This is jacked, we have to fix this, will not send password correct send_password($fh, $password); #$fh ->send("$password\r"); exp_continue; } ], [ '-re','state:.*Connected', sub { my $fh = shift; $connected = 1; if ($vars{"debug"}){ print "AnyConnectShellWrapper::connect successful connect\n"; } } ], [ '-re','VPN>$', sub { my $fh = shift; exp_continue; } ], [ eof => sub { die "ERROR: premature EOF in vpn shell.\n"; } ], [ timeout => sub { die "No prompt.\n"; } ] ); if ($vars{"debug"}){ print "Exiting AnyConnectShellWrapper::connect with return code of $connected\n"; } return $connected; } 2. Had some comments on my regular expressions, you guys are right. I should not be checking for Password:\s*, this wsa in there due to frustrations of trying to figure out why the password was not being accepted. Added back proper reg expression 3. Tried a recommendation to sleep to allow the application to prepare for password acceptance. See code. Thanks again, Jonathan > On Wed, Jul 21, 2010 at 09:39:50AM -0400, Jonathan wrote: >> I have an application, a client module that control a server module, >> that my group is automating tests for. This may be a cygwin problem, >> I will have to try on a cross platform system as the server/client >> model runs on Windows/Linux/Mac. However, does anyone have any >> insight into why I can't send a password to this application with >> cygwin. >> >> Output: >> VPN> connect as5505-1.testbed >> >> contacting host as5505-1.testbed.cisco.com) for login information... >> >> notice: Contactingas5505-1.testbed >> VPN> >> >> Please enter your username and password. >> Group: SSLVPNClient >> >> Username: [userA] userA >> Password: test123 ************************* this is the >> password, it picked up the password prompt but never is accepted.... I >> can enter keystroke right when displaying as test123 and it will >> connect. >> No prompt. >> >> >> Code: >> >> sub connect { >> >> if ($VpnHelper::Debug){ >> print "Entering VpnHelper::connect\n"; >> } >> >> my ($self, $hostname, $username, $password, $group) = @_; >> my $exp = $self->{exp}; >> my $connected = 0; >> >> if ($VpnHelper::Debug){ >> print "Username is $username\n"; >> print "Password is $password\n"; >> print "Group is $group\n"; >> print "Hostname is $hostname\n"; >> } >> >> >> #Make sure VPN is not already up >> if ($self->connected){ >> return $connected; >> } >> >> $exp->send("connect $hostname\r"); >> $exp->expect(15, >> [ >> '-re','Username:\s*(.*)', >> sub { >> my $fh = shift; >> $fh->send("$username\r"); >> exp_continue; >> } >> ], >> [ >> '-re','Password:\s*', >> sub { >> my $fh = shift; >> $fh ->send("$password\r"); >> exp_continue; >> } >> ], >> [ >> '-re','state:\sConnected', >> sub { >> my $fh = shift; >> $connected = 1; >> exp_continue; >> } >> ], >> [ >> '-re','VPN>', >> sub { >> my $fh = shift; >> exp_continue; >> } >> >> ], >> >> [ >> eof => >> sub { >> die "ERROR: premature EOF in vpn shell.\n"; >> } >> ], >> [ >> timeout => >> sub { >> die "No prompt.\n"; >> } >> ] >> ); >> >> } >> >> Thank you in advance, >> Jonathan >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Sprint >> What will you do first with EVO, the first 4G phone? >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first >> _______________________________________________ >> Expectperl-discuss mailing list >> Exp...@li... >> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > -- > http://singinst.org/ : Our last, best hope for a fantastic future. > Lojban (http://www.lojban.org/): The language in which "this parrot > is dead" is "ti poi spitaki cu morsi", but "this sentence is false" > is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ > |
From: Robin L. P. <rlp...@di...> - 2010-07-21 18:02:03
|
I don't know cygwin at all, but on normal linux or whatever it matters very much *how* you open the terminal, because passwords are often read differently than other things. Can you show us where $self->{exp}; is defined? Basically, *any* Expect related calls that occur before the code below? -Robin On Wed, Jul 21, 2010 at 09:39:50AM -0400, Jonathan wrote: > I have an application, a client module that control a server module, > that my group is automating tests for. This may be a cygwin problem, > I will have to try on a cross platform system as the server/client > model runs on Windows/Linux/Mac. However, does anyone have any > insight into why I can't send a password to this application with > cygwin. > > Output: > VPN> connect as5505-1.testbed > >> contacting host as5505-1.testbed.cisco.com) for login information... > >> notice: Contactingas5505-1.testbed > VPN> > >> Please enter your username and password. > Group: SSLVPNClient > > Username: [userA] userA > Password: test123 ************************* this is the > password, it picked up the password prompt but never is accepted.... I > can enter keystroke right when displaying as test123 and it will > connect. > No prompt. > > > Code: > > sub connect { > > if ($VpnHelper::Debug){ > print "Entering VpnHelper::connect\n"; > } > > my ($self, $hostname, $username, $password, $group) = @_; > my $exp = $self->{exp}; > my $connected = 0; > > if ($VpnHelper::Debug){ > print "Username is $username\n"; > print "Password is $password\n"; > print "Group is $group\n"; > print "Hostname is $hostname\n"; > } > > > #Make sure VPN is not already up > if ($self->connected){ > return $connected; > } > > $exp->send("connect $hostname\r"); > $exp->expect(15, > [ > '-re','Username:\s*(.*)', > sub { > my $fh = shift; > $fh->send("$username\r"); > exp_continue; > } > ], > [ > '-re','Password:\s*', > sub { > my $fh = shift; > $fh ->send("$password\r"); > exp_continue; > } > ], > [ > '-re','state:\sConnected', > sub { > my $fh = shift; > $connected = 1; > exp_continue; > } > ], > [ > '-re','VPN>', > sub { > my $fh = shift; > exp_continue; > } > > ], > > [ > eof => > sub { > die "ERROR: premature EOF in vpn shell.\n"; > } > ], > [ > timeout => > sub { > die "No prompt.\n"; > } > ] > ); > > } > > Thank you in advance, > Jonathan > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss -- http://singinst.org/ : Our last, best hope for a fantastic future. Lojban (http://www.lojban.org/): The language in which "this parrot is dead" is "ti poi spitaki cu morsi", but "this sentence is false" is "na nei". My personal page: http://www.digitalkingdom.org/rlp/ |
From: Jonathan <jws...@gm...> - 2010-07-21 13:48:21
|
I have an application, a client module that control a server module, that my group is automating tests for. This may be a cygwin problem, I will have to try on a cross platform system as the server/client model runs on Windows/Linux/Mac. However, does anyone have any insight into why I can't send a password to this application with cygwin. Output: VPN> connect as5505-1.testbed >> contacting host as5505-1.testbed.cisco.com) for login information... >> notice: Contactingas5505-1.testbed VPN> >> Please enter your username and password. Group: SSLVPNClient Username: [userA] userA Password: test123 ************************* this is the password, it picked up the password prompt but never is accepted.... I can enter keystroke right when displaying as test123 and it will connect. No prompt. Code: sub connect { if ($VpnHelper::Debug){ print "Entering VpnHelper::connect\n"; } my ($self, $hostname, $username, $password, $group) = @_; my $exp = $self->{exp}; my $connected = 0; if ($VpnHelper::Debug){ print "Username is $username\n"; print "Password is $password\n"; print "Group is $group\n"; print "Hostname is $hostname\n"; } #Make sure VPN is not already up if ($self->connected){ return $connected; } $exp->send("connect $hostname\r"); $exp->expect(15, [ '-re','Username:\s*(.*)', sub { my $fh = shift; $fh->send("$username\r"); exp_continue; } ], [ '-re','Password:\s*', sub { my $fh = shift; $fh ->send("$password\r"); exp_continue; } ], [ '-re','state:\sConnected', sub { my $fh = shift; $connected = 1; exp_continue; } ], [ '-re','VPN>', sub { my $fh = shift; exp_continue; } ], [ eof => sub { die "ERROR: premature EOF in vpn shell.\n"; } ], [ timeout => sub { die "No prompt.\n"; } ] ); } Thank you in advance, Jonathan |
From: Matt Z. <mzagrabe@d.umn.edu> - 2010-06-17 11:51:15
|
On Fri, 2010-06-11 at 12:52 -0600, Tom Hall wrote: > How do I do a case insensitive match like with the ‘-nocase’ flag with > expect ? $exp->expect($timeout, [ qr/regex1/ => sub { my $exp = shift; $exp->send("response\n"); exp_continue; } ], [ "regexp2" , \&callback, @cbparms ], ); In perl, you use the 'i' flag with your regexes: "What" =~ /what/ # does not match "What" =~ /what/i # does match HTH, -- Matt Zagrabelny - mzagrabe@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 4096R/42A00942 2009-12-16 Fingerprint: 5814 2CCE 2383 2991 83FF C899 07E2 BFA8 42A0 0942 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot |
From: Tom H. <Tom...@do...> - 2010-06-11 19:26:57
|
How do I do a case insensitive match like with the '-nocase' flag with expect ? -- Tom Hall Sr. Test Development Engineer Dot Hill Technology Center 1351 South Sunset Street Longmont CO 80501 303 845-3213 |
From: Ron S. <gee...@ya...> - 2010-05-26 04:15:25
|
http://yatojunu.angelfire.com/ |
From: Atul P. <atu...@ya...> - 2010-05-24 15:54:36
|
Folks, I have the following script to programme the BIOS on an embedded system. I login using a password, select a menu option (by sending $opt), give a description (by sending $description) then finally send the binary file. I'm currently using "cat filename >> /dev/ttyUSB0" in a seperate terminal window, but I want to do this within the script itself. Whats the correct way of sending a binary file using Expect ? thanks for any suggesstions! a. $k = new Expect(); $k->raw_pty(1); $k->spwan(kermit -l $dev_port -q -c -b 115200) $k->send("\n"); $k->expect(45, ['-re', qr/\>/ => sub { $k->send("password\n"); $k->exp_continue; } ], ['-re', qr/\* MyBIOS/ => sub { $k->send("$opt"); $k->exp_continue(); } ], ['-re', qr/Enter FW description:/ => sub { my $fw_file = $options{$opt}->[1]; my $description = $options{$opt}->[0]; print "\n=======================================================\n"; print "sending description $description\n"; $k->send("$description\n"); print "sending binary to $dev_port \n"; print "cat $fw_file >> $dev_port\n"; # system("cat $fw_file >> $dev_port"); # `cat $fw_file >> $dev_port`; print `cat $fw_file > $dev_port`; # `cat $fw_file >> $dev_port`; $k->expect(165, '-re', qr/Downloading/ => sub { print "controller accepted start of binary\n"; $k->expect(150, [ '-re', qr/Erase sector/ => sub { print "... ok\n"; $k->exp_continue(); } ], [ '-re', qr/flashWriteChunk.*complete/ => sub { print "Flash write complete\n"; } ] ); }); print "=======================================================\n"; } ], ); |
From: Roland G. <rgi...@cp...> - 2010-03-30 09:20:28
|
You can avoid all that hassle by doing the TCP connect directly in perl (directly with Socket or maybe with a little help from a nice CPAN module) and not in a spawned netcat. Expect doesn't need to spawn a program, it can also take a filehandle and work on that. Hope this helps, Roland Ken Irving schrieb: > Using Expect.pm 1.15, occasionally the spawned process fails for unknown > reasons. Up to now we just exit the program, but I'd like to give it > another try. I'm not clear on what exactly to retry, though. > > The code segment is currently: > > my $exp = Expect->new(); > $exp->raw_pty(1); > $exp->debug($debug); > $exp->log_file($nc_log) if $nc_log; > $exp->spawn("/bin/nc", $host, $port) > or die "Cannot spawn nc: $!\n"; > $exp->expect(10, '-re', 'CoraScript.*$') > or log_session('NO_CORA_CMD'); # log_session() invokes die() > > The process is spawned, but the subsequent expect() times out. > > I could perhaps do something like the following, i.e., just abandon the > Expect object (not tested): > > my $exp; > my $retries = 3; > while ( $retries ) { > $retries -= 1; > $exp = Expect->new(); > $exp->raw_pty(1); > $exp->debug($debug); > $exp->log_file($nc_log) if $nc_log; > $exp->spawn("/bin/nc", $host, $port) > or die "Cannot spawn nc: $!\n"; > break if $exp->expect(10, '-re', 'CoraScript.*$'); > $exp->hard_close(); > undef $exp; > } > log_session('NO_CORA_CMD') unless $exp; > ... > > But is there a cleaner or better way to approach this? > > Thanks for any hints or pointers, examples, etc. > > Ken > > |
From: Ken I. <ki....@al...> - 2010-03-26 03:51:12
|
(message resent with updated email address) Using Expect.pm 1.15, occasionally the spawned process fails for unknown reasons. Up to now we just exit the program, but I'd like to give it another try. I'm not clear on what exactly to retry, though. The code segment is currently: my $exp = Expect->new(); $exp->raw_pty(1); $exp->debug($debug); $exp->log_file($nc_log) if $nc_log; $exp->spawn("/bin/nc", $host, $port) or die "Cannot spawn nc: $!\n"; $exp->expect(10, '-re', 'CoraScript.*$') or log_session('NO_CORA_CMD'); # log_session() invokes die() The process is spawned, but the subsequent expect() times out. I could perhaps do something like the following, i.e., just abandon the Expect object (not tested): my $exp; my $retries = 3; while ( $retries ) { $retries -= 1; $exp = Expect->new(); $exp->raw_pty(1); $exp->debug($debug); $exp->log_file($nc_log) if $nc_log; $exp->spawn("/bin/nc", $host, $port) or die "Cannot spawn nc: $!\n"; break if $exp->expect(10, '-re', 'CoraScript.*$'); $exp->hard_close(); undef $exp; } log_session('NO_CORA_CMD') unless $exp; ... But is there a cleaner or better way to approach this? Thanks for any hints or pointers, examples, etc. Ken -- Ken...@al..., 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks |
From: Ken I. <ken...@al...> - 2010-03-26 03:35:47
|
Using Expect.pm 1.15, occasionally the spawned process fails for unknown reasons. Up to now we just exit the program, but I'd like to give it another try. I'm not clear on what exactly to retry, though. The code segment is currently: my $exp = Expect->new(); $exp->raw_pty(1); $exp->debug($debug); $exp->log_file($nc_log) if $nc_log; $exp->spawn("/bin/nc", $host, $port) or die "Cannot spawn nc: $!\n"; $exp->expect(10, '-re', 'CoraScript.*$') or log_session('NO_CORA_CMD'); # log_session() invokes die() The process is spawned, but the subsequent expect() times out. I could perhaps do something like the following, i.e., just abandon the Expect object (not tested): my $exp; my $retries = 3; while ( $retries ) { $retries -= 1; $exp = Expect->new(); $exp->raw_pty(1); $exp->debug($debug); $exp->log_file($nc_log) if $nc_log; $exp->spawn("/bin/nc", $host, $port) or die "Cannot spawn nc: $!\n"; break if $exp->expect(10, '-re', 'CoraScript.*$'); $exp->hard_close(); undef $exp; } log_session('NO_CORA_CMD') unless $exp; ... But is there a cleaner or better way to approach this? Thanks for any hints or pointers, examples, etc. Ken -- Ken...@al..., 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks |
From: GPx <pur...@bu...> - 2010-02-23 00:03:54
|
IO::Tty install reports: Configuration looks good! but makfile fails with missing Tty.so Any suggestions? ------------------ # perl Makefile.PL Now let's see what we can find out about your system (logfiles of failing tests are available in the conf/ dir)... Looking for _getpty()...... not found. Looking for getpt()........ not found. Looking for grantpt()...... FOUND. Looking for openpty()...... not found. Looking for posix_openpt(). FOUND. Looking for ptsname()...... FOUND. Looking for ptsname_r().... not found. Looking for sigaction().... FOUND. Looking for strlcpy()...... FOUND. Looking for ttyname()...... FOUND. Looking for unlockpt()..... FOUND. Looking for libutil.h...... not found. Looking for pty.h.......... not found. Looking for sys/pty.h...... not found. Looking for sys/ptyio.h.... not found. Looking for sys/stropts.h.. FOUND. Looking for termio.h....... FOUND. Looking for termios.h...... FOUND. Looking for util.h......... not found. Checking which symbols compile OK... (sorry for the tedious check, but some systems have not too clean header files, to say the least; '+' means OK, '-' means not defined and '*' has compile problems...) +B0 +B110 +B115200 +B1200 +B134 +B150 +B153600 +B1800 +B19200 +B200 +B230400 +B2 400 +B300 +B307200 +B38400 +B460800 +B4800 +B50 +B57600 +B600 +B75 +B76800 +B960 0 +BRKINT +BS0 +BS1 +BSDLY +CBAUD +CBAUDEXT -CBRK +CCTS_OFLOW +CDEL +CDSUSP +CEO F +CEOL +CEOL2 +CEOT +CERASE +CESC +CFLUSH +CIBAUD +CIBAUDEXT +CINTR +CKILL +CLN EXT +CLOCAL +CNSWTCH +CNUL +CQUIT +CR0 +CR1 +CR2 +CR3 +CRDLY +CREAD +CRPRNT +CRT SCTS +CRTSXOFF +CRTS_IFLOW +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTART +CSTOP +CSTOPB +CS USP +CSWTCH +CWERASE +DEFECHO +DIOC +DIOCGETP +DIOCSETP +DOSMODE +ECHO +ECHOCTL +ECHOE +ECHOK +ECHOKE +ECHONL +ECHOPRT +EXTA +EXTB +FF0 +FF1 +FFDLY +FIORDCHK +F LUSHO +HUPCL +ICANON +ICRNL +IEXTEN +IGNBRK +IGNCR +IGNPAR +IMAXBEL +INLCR +INPC K +ISIG +ISTRIP +IUCLC +IXANY +IXOFF +IXON +KBENABLED +LDCHG +LDCLOSE +LDDMAP +L DEMAP +LDGETT +LDGMAP +LDIOC +LDNMAP +LDOPEN +LDSETT +LDSMAP +LOBLK +NCCS +NL0 + NL1 +NLDLY +NOFLSH +OCRNL +OFDEL +OFILL +OLCUC +ONLCR +ONLRET +ONOCR +OPOST +PAG EOUT +PARENB +PAREXT +PARMRK +PARODD +PENDIN +RCV1EN +RTS_TOG +TAB0 +TAB1 +TAB2 +TAB3 +TABDLY +TCDSET +TCFLSH +TCGETA +TCGETS +TCIFLUSH +TCIOFF +TCIOFLUSH +TCIO N +TCOFLUSH +TCOOFF +TCOON +TCSADRAIN +TCSAFLUSH +TCSANOW +TCSBRK +TCSETA +TCSET AF +TCSETAW -TCSETCTTY +TCSETS +TCSETSF +TCSETSW +TCXONC +TERM_D40 +TERM_D42 +TE RM_H45 +TERM_NONE +TERM_TEC +TERM_TEX +TERM_V10 +TERM_V61 +TIOCCBRK +TIOCCDTR -T IOCCONS +TIOCEXCL +TIOCFLUSH +TIOCGETC +TIOCGETD +TIOCGETP +TIOCGLTC +TIOCGPGRP +TIOCGSID +TIOCGSOFTCAR +TIOCGWINSZ +TIOCHPCL +TIOCKBOF +TIOCKBON +TIOCLBIC +TIO CLBIS +TIOCLGET +TIOCLSET +TIOCMBIC +TIOCMBIS +TIOCMGET +TIOCMSET +TIOCM_CAR +TI OCM_CD +TIOCM_CTS +TIOCM_DSR +TIOCM_DTR +TIOCM_LE +TIOCM_RI +TIOCM_RNG +TIOCM_RT S +TIOCM_SR +TIOCM_ST +TIOCNOTTY +TIOCNXCL +TIOCOUTQ +TIOCREMOTE +TIOCSBRK +TIOC SCTTY +TIOCSDTR +TIOCSETC +TIOCSETD +TIOCSETN +TIOCSETP +TIOCSIGNAL +TIOCSLTC +T IOCSPGRP -TIOCSSID +TIOCSSOFTCAR +TIOCSTART +TIOCSTI +TIOCSTOP +TIOCSWINSZ +TM_A NL +TM_CECHO +TM_CINVIS +TM_LCF +TM_NONE +TM_SET +TM_SNL +TOSTOP +VCEOF +VCEOL + VDISCARD +VDSUSP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VLNEXT +VMIN +VQUIT +VREPRINT +VSTART +VSTOP +VSUSP +VSWTCH +VT0 +VT1 +VTDLY +VTIME +VWERASE +WRAP +XCASE +XCLUDE +XMT1EN +XTABS >>> Configuration looks good! <<< Writing IO::Tty::Constant.pm... DEFINE = -DHAVE_DEV_PTMX -DHAVE_GRANTPT -DHAVE_POSIX_OPENPT -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_SYS_STROPTS_H -DHAVE_TERMIOS_H -DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT Writing Makefile for IO::Tty # -------------------------------- # /usr/sfw/bin/gmake Skip blib/lib/IO/Tty.pm (unchanged) Skip blib/lib/IO/Tty/Constant.pm (unchanged) Skip blib/lib/IO/Pty.pm (unchanged) cc -c -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -xO3 -xspace -xildoff -DVERSION=\"1.08\" -DXS_VERSION=\"1.08\" -KPIC "-I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE" -DHAVE_DEV_PTMX -DHAVE_GRANTPT -DHAVE_POSIX_OPENPT -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_SYS_STROPTS_H -DHAVE_TERMIOS_H -DHAVE_TERMIO_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT Tty.c cc: unrecognized option `-KPIC' cc: language ildoff not recognized cc: Tty.c: linker input file unused because linking not done Running Mkbootstrap for IO::Tty () chmod 644 Tty.bs rm -f blib/arch/auto/IO/Tty/Tty.so LD_RUN_PATH="" cc -G Tty.o -o blib/arch/auto/IO/Tty/Tty.so cc: Tty.o: No such file or directory cc: no input files gmake: *** [blib/arch/auto/IO/Tty/Tty.so] Error 1 -- View this message in context: http://old.nabble.com/IO%3A%3APty-Makefile-fails-tp27695405p27695405.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Roland G. <rgi...@cp...> - 2010-01-25 23:27:25
|
Hi Chap, no need to use Expect for that, I'd recommend using File::Tail instead. It can tail multiple files at once and you can handle each line separately, which is easier than emulating that with Expect. Hope this helps, Roland Chap Harrison schrieb: > First of all, this may be considered purely an Expect question, but I do > intend to use Expect.pm, and I can't seem to find a viable Expect forum > anywhere else. > > My job entails running a GUI-driven school district data conversion program. > This involves (a) selecting a school, (b) clicking "convert school", and (c) > moving the output files - of which there are about 15 - to a safe location > when the conversion is finished, which can take between 3 minutes and 1.5 > hours. Then I start again at (a), selecting the next school in the > district. > > The GUI also has a button labelled "convert entire district". You'd think > it would alleviate the need to babysit on a school-by-school basis, but it > doesn't: it OVERWRITES the output files for each new school! Unfortunately, > we don't own the source and can't fix this obviously broken behavior, so we > have had to live with converting on a school-by-school basis. > > However, the conversion program *does* write log files - a separate one for > each of the 15 output files it creates. And happily, it appends to - rather > than overwriting - each one! > > I want to work around the flaw in the "convert entire district" > functionality with an Expect program, as follows: > > - spawn the Unix 'tail -f' command to watch each log file, > - look for the messages indicating that the conversion program has finished > writing a file, > - rename the file with a unique qualifier so that it won't be overwritten > when the conversion circles around to the next school. > > NOTE that once conversion finishes one file (e.g. Students), it starts a > different one (e.g. Schedules) with a different file name. As I mentioned, > converting a school produces around 15 different files, and it takes a > minimum of about 3 minutes per school. So, while my Expect script would be > "racing" to rename the output file before the conversion program circles > around to start the next school, there is a multi-minute window of time in > which to do so. > > Here's a simplified example of one log file: > > Students.log > - - - - - > initialization preamble > blah blah blah > THIS MESSAGE INDICATES BEGINNING OF A CONVERSION > blah blah blah > more blah blah blah > THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: 003 > blah blah blah > lots more blah blah blah - hundreds of lines > : : : > THIS MESSAGE INDICATES END OF A FILE CONVERSION > blah blah blah > yadda yadda yadda > THIS MESSAGE INDICATES BEGINNING OF A FILE CONVERSION > blah blah blah > more blah blah blah > THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: 003 > blah blah blah > lots more blah blah blah - hundreds of lines > : : : > THIS MESSAGE INDICATES END OF A FILE CONVERSION > blah blah blah > yadda yadda yadda > THIS MESSAGE INDICATES BEGINNING OF A FILE CONVERSION > blah blah blah > etc. > - - - - - > > Here are the simplified guts of my program (in TCL): > > # Spawn a 'tail' process for each log file > foreach file $logfiles { > spawn -noecho /usr/bin/tail -f $file > lappend spawn_id_list $spawn_id > } > > # Watch for significant output > while {1} { > expect { > -i $spawn_id_list > > -exact {THIS MESSAGE INDICATES BEGINNING OF A CONVERSION} { > } > > -re {THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: (\d\d\d)} { > } > > -exact {THIS MESSAGE INDICATES END OF A FILE CONVERSION} { > # Give the output file a unique name by appending school id > } > } > } > > I've obviously left out a lot here. One problem I've been having is that > sometimes Expect "misses" the end-of-conversion message, and I think that's > because the end-of-conversion message and the next beginning-of-conversion > message happen so closely to one another that sometimes they appear together > in the same buffer Expect examines. Since "BEGINNING..." will be searched > (and found) before "END...", this could be my problem. > > I'm wondering how to get around this problem, and wondering, too, if this is > the best way to approach the whole thing. > > Incidentally, I want to use Perl rather than TCL because I encountered bugs > with TCL in CygWin, whereas Perl has always been reliable on that platform. > |
From: Chap H. <cl...@po...> - 2010-01-25 20:51:09
|
First of all, this may be considered purely an Expect question, but I do intend to use Expect.pm, and I can't seem to find a viable Expect forum anywhere else. My job entails running a GUI-driven school district data conversion program. This involves (a) selecting a school, (b) clicking "convert school", and (c) moving the output files - of which there are about 15 - to a safe location when the conversion is finished, which can take between 3 minutes and 1.5 hours. Then I start again at (a), selecting the next school in the district. The GUI also has a button labelled "convert entire district". You'd think it would alleviate the need to babysit on a school-by-school basis, but it doesn't: it OVERWRITES the output files for each new school! Unfortunately, we don't own the source and can't fix this obviously broken behavior, so we have had to live with converting on a school-by-school basis. However, the conversion program *does* write log files - a separate one for each of the 15 output files it creates. And happily, it appends to - rather than overwriting - each one! I want to work around the flaw in the "convert entire district" functionality with an Expect program, as follows: - spawn the Unix 'tail -f' command to watch each log file, - look for the messages indicating that the conversion program has finished writing a file, - rename the file with a unique qualifier so that it won't be overwritten when the conversion circles around to the next school. NOTE that once conversion finishes one file (e.g. Students), it starts a different one (e.g. Schedules) with a different file name. As I mentioned, converting a school produces around 15 different files, and it takes a minimum of about 3 minutes per school. So, while my Expect script would be "racing" to rename the output file before the conversion program circles around to start the next school, there is a multi-minute window of time in which to do so. Here's a simplified example of one log file: Students.log - - - - - initialization preamble blah blah blah THIS MESSAGE INDICATES BEGINNING OF A CONVERSION blah blah blah more blah blah blah THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: 003 blah blah blah lots more blah blah blah - hundreds of lines : : : THIS MESSAGE INDICATES END OF A FILE CONVERSION blah blah blah yadda yadda yadda THIS MESSAGE INDICATES BEGINNING OF A FILE CONVERSION blah blah blah more blah blah blah THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: 003 blah blah blah lots more blah blah blah - hundreds of lines : : : THIS MESSAGE INDICATES END OF A FILE CONVERSION blah blah blah yadda yadda yadda THIS MESSAGE INDICATES BEGINNING OF A FILE CONVERSION blah blah blah etc. - - - - - Here are the simplified guts of my program (in TCL): # Spawn a 'tail' process for each log file foreach file $logfiles { spawn -noecho /usr/bin/tail -f $file lappend spawn_id_list $spawn_id } # Watch for significant output while {1} { expect { -i $spawn_id_list -exact {THIS MESSAGE INDICATES BEGINNING OF A CONVERSION} { } -re {THIS IS THE ID OF THE SCHOOL WE'RE CONVERTING: (\d\d\d)} { } -exact {THIS MESSAGE INDICATES END OF A FILE CONVERSION} { # Give the output file a unique name by appending school id } } } I've obviously left out a lot here. One problem I've been having is that sometimes Expect "misses" the end-of-conversion message, and I think that's because the end-of-conversion message and the next beginning-of-conversion message happen so closely to one another that sometimes they appear together in the same buffer Expect examines. Since "BEGINNING..." will be searched (and found) before "END...", this could be my problem. I'm wondering how to get around this problem, and wondering, too, if this is the best way to approach the whole thing. Incidentally, I want to use Perl rather than TCL because I encountered bugs with TCL in CygWin, whereas Perl has always been reliable on that platform. -- View this message in context: http://old.nabble.com/Logfile-watching-program---design-questions-tp27313339p27313339.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Atul P. <atu...@ya...> - 2009-12-14 13:10:49
|
Austin, thanks for your suggestion ! it's ideal for my scenario. From the property command being issued (@Q06); Response = :Q0615000000050000001200000005000000 i.e. :<property><data> o I know the size of the data being returned (32). o Also the response string contains the command itself (:Q06) This is what I ended up doing; $property = Q06 $response_size = 32 $k->expect(5, '-re', qr/:Q$property\S{$response_size}\r\n/ ); $query_value = $k->match(); Some of my commands return a variable size data but I always know the min and max i.e. my regex can be tailored ... \S{n,m} cheers atul. P.S. I'm also able to remove the sleep! ----- Original Message ---- From: Austin Schutz <te...@of...> To: Atul Patel <atu...@ya...> Cc: exp...@li... Sent: Fri, 11 December, 2009 18:39:43 Subject: Re: [Expectperl-discuss] perl expect regex problem Atul Patel wrote: > folks, > > I'm trying to put together a regex, but failing to see how I can do it correctly. > > The string being returned & captured is of the style, > :Q0615000000050000001200000005000000 > >>From the command I send, I know the first four characters will be " :Q06 " , so I'm using the following the following expect to capture > the returned string. > > > $k->clear_accum(); > $k->send_slow(1, "$command Q06"); > $k->expect(5, ":Q06"); > $query_value = $k->after(); > > However, every so often there appears to be a race condition. The match for :Q06 occurs, but the string $k->after() manages to > run before the rest of the digits have been returned. Typical methodology is to expect() the string that comes _after_ what you want to capture, then save what comes before it, for the reasons you indicate. If you don't have a terminating string to look for you could expect() a specific number of any character using something like '-re' '\S{40}', which would match a fixed 40 character non-whitespace string (assuming you are looking for a fixed length string). If that's not possible then sleeping is about the best you can do. I have had to use sleeps in my code, which generally works well but leaves one feeling a little uneasy- even with a sleep you aren't guaranteed the output will arrive in time, and it "unnecessarily" slows down the code. Austin ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Bryan B. <br...@bu...> - 2009-12-11 16:16:40
|
> I inserted a "sleep 1; " before the $k->after(); this appears to work, > but I'd rathernot start introducing sleeps into the code. > I use "sleep" in alot of my code, sometimes i think its unavoidable. Instead of sleep 1; try using select with a timeout of a quarter second: select (undef, undef, undef, 0.25); Or a half second: select (undef, undef, undef, 0.50); Much less time, and produces the same result. Hope that helps, Bryan Bueter http://sourceforge.net/projects/rover |
From: Atul P. <atu...@ya...> - 2009-12-11 12:49:18
|
folks, I'm trying to put together a regex, but failing to see how I can do it correctly. The string being returned & captured is of the style, :Q0615000000050000001200000005000000 From the command I send, I know the first four characters will be " :Q06 " , so I'm using the following the following expect to capture the returned string. $k->clear_accum(); $k->send_slow(1, "$command Q06"); $k->expect(5, ":Q06"); $query_value = $k->after(); However, every so often there appears to be a race condition. The match for :Q06 occurs, but the string $k->after() manages to run before the rest of the digits have been returned. I inserted a "sleep 1; " before the $k->after(); this appears to work, but I'd rathernot start introducing sleeps into the code. I tried the following to be more explicit; $k->expect(5, '-re', qr/^:Q06.*$/); # match all characters to the end of the line $query_value = $k->match(); # and grab the match but this didn't work either, so I'm confused why this behaved in the same way; I know exactly how many characters expect in the match but not sure how to use this to match the entire string? any help, pointers would be appreciated! atts. |
From: Juan P. F. G. <jfe...@gm...> - 2009-11-20 22:54:10
|
if its cisco a router, here is a nasty trick that worked for me... $exp->send("$cmd"); $exp->send("!"); then wait for "routerprompt>!" in $exp->expect let us know if worked for you :) Good luck Juan Pablo On Fri, Nov 20, 2009 at 1:40 PM, Zed <zed...@gm...> wrote: > Hello. I'm trying to use perl Expect to fetch a large (500k or so) > configuration dump from a router via ssh. I wrote a small sub to help: > > sub SendExpect > { > my $cmd = shift; > my $pat = shift; > > $exp->send("$cmd"); > $exp->expect($C_timeout, '-re', $pat?$pat:$prompt); > > return $exp->before(); > } > > I call this sub to send a few admin commands first, which return output > as expected. I then send the command to dump the full router config. The > call to SendExpect returns only the first 150k or so of the config, > sometimes as much as 170k, sometimes only about 100k. > > The next call to SendExpect sends another admin command. However, this > call returns more of the router config from the previous call, not the > output of the admin command. > > I can't figure out what I'm doing wrong here or how to fix it. Can > anyone help me? > > Thanks. > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Zed <zed...@gm...> - 2009-11-20 20:40:19
|
Hello. I'm trying to use perl Expect to fetch a large (500k or so) configuration dump from a router via ssh. I wrote a small sub to help: sub SendExpect { my $cmd = shift; my $pat = shift; $exp->send("$cmd"); $exp->expect($C_timeout, '-re', $pat?$pat:$prompt); return $exp->before(); } I call this sub to send a few admin commands first, which return output as expected. I then send the command to dump the full router config. The call to SendExpect returns only the first 150k or so of the config, sometimes as much as 170k, sometimes only about 100k. The next call to SendExpect sends another admin command. However, this call returns more of the router config from the previous call, not the output of the admin command. I can't figure out what I'm doing wrong here or how to fix it. Can anyone help me? Thanks. |
From: avonnieda <ad...@vo...> - 2009-11-10 14:06:47
|
Thanks very much for the replies folks, very helpful. -Adam avonnieda wrote: > > > Hi Folks, > > I have one line in a program I'm automating that will prompt sometimes, > not always. How can I make an expect line "optional". In other words, > ignore this block if you don't see the string before the timeot is > reached. Here's the block I want to make optional. > > $expect->expect($timeout,"Do you want to preserve the port number"); > $expect->send("n\n"); > > Thanks very much for any insight. > > -Adam > > > -- View this message in context: http://old.nabble.com/How-to-make-an-expect-string-optional-tp26230867p26283978.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Roland G. <rgi...@cp...> - 2009-11-10 10:02:51
|
Use a multi-expect with callback and exp_continue: $expect->expect($timeout, [ qr/Do you want to preserve the port number/ , sub { my $self = shift; $self->send("n\n"); exp_continue; }], [ qr/prompt>/, sub {}], ); See the man page for details. Hope this helps, Roland avonnieda schrieb: > Hi Folks, > > I have one line in a program I'm automating that will prompt sometimes, > not always. How can I make an expect line "optional". In other words, ignore > this block if you don't see the string before the timeot is reached. Here's > the block I want to make optional. > > $expect->expect($timeout,"Do you want to preserve the port number"); > $expect->send("n\n"); > > Thanks very much for any insight. > > -Adam > > > |