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) |
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
(8) |
9
(7) |
10
|
11
|
12
|
13
|
14
|
15
|
16
|
17
(4) |
18
|
19
|
20
|
21
|
22
|
23
(1) |
24
|
25
|
26
|
27
|
28
|
29
|
30
|
31
|
|
|
From: Roland G. <rgi...@cp...> - 2007-05-23 15:22:23
|
how about adjusting your regex to deal with one complete line after another? something like "Internet.*\n"? hope this helps, roland On 5/17/07, Jason Gerdes <JG...@cw...> wrote: > Hello, > > Here is the problem I am having: > > I use expect to spawn an SSH session to a cisco router and run the command 'show arp', which sends a lot of data back. example: > > gw>show arp > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c525.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > ... (there are thousands of lines sent back) > > The problem I get is that expect seems to process this data in chunks. For example, it will process: > > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c5 > > where it will pull out the data correctly for the first line, but will not match the second line since it is incomplete. Then, it processes the next chunk. example: > > 25.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > > where it will not pull the data correctly for the first line (incomplete), but will pull the correct data for the second line. > > I have used the TCL expect before and it does the same thing so I know it is not a bug. I think there is just a gap in my understanding of how expect processes the data that is sent back from spawned processes. > > Is there a way to make expect deal with all of the data as one big chunk, rather than processing it in pieces? I hope someone can explain how this works. > > > > --Jason > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Jason G. <JG...@cw...> - 2007-05-17 20:45:14
|
Thanks to both who answered this question. I was able to use both of your = suggestions and my script is working now. Thanks a lot!! --Jason >>> Jason Gerdes <JG...@cw...> 5/17/2007 11:53 AM >>> Hello, Here is the problem I am having: I use expect to spawn an SSH session to a cisco router and run the command = 'show arp', which sends a lot of data back. example: gw>show arp Protocol Address Age (min) Hardware Addr Type Interface Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 Internet XX.XX.97.28 171 XXXX.c525.d4c3 ARPA Vlan122 Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 ... (there are thousands of lines sent back) The problem I get is that expect seems to process this data in chunks. = For example, it will process: Protocol Address Age (min) Hardware Addr Type Interface Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 Internet XX.XX.97.28 171 XXXX.c5 where it will pull out the data correctly for the first line, but will not = match the second line since it is incomplete. Then, it processes the next = chunk. example: 25.d4c3 ARPA Vlan122 Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 where it will not pull the data correctly for the first line (incomplete), = but will pull the correct data for the second line. I have used the TCL expect before and it does the same thing so I know it = is not a bug. I think there is just a gap in my understanding of how = expect processes the data that is sent back from spawned processes. Is there a way to make expect deal with all of the data as one big chunk, = rather than processing it in pieces? I hope someone can explain how this = works. --Jason ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/=20 _______________________________________________ Expectperl-discuss mailing list Exp...@li...=20 https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Matt Z. <mzagrabe@d.umn.edu> - 2007-05-17 19:45:23
|
> Is there a way to make expect deal with all of the data as one big chunk,= rather than processing it in pieces? I hope someone can explain how this = works. not to my knowledge, though a work-around that i have used is to write everything to a buffer (continually appending the data that expect returns). next, split'ing the data in that scalar (buffer) into an array of lines. finally, doing a 'foreach' on the array of lines and processing as i normally would. --=20 Matt Zagrabelny - mzagrabe@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot |
From: Ken I. <fn...@ua...> - 2007-05-17 19:10:18
|
On Thu, May 17, 2007 at 11:53:52AM -0700, Jason Gerdes wrote: > Hello, > > Here is the problem I am having: > > I use expect to spawn an SSH session to a cisco router and run the > command 'show arp', which sends a lot of data back. example: > > gw>show arp > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c525.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > ... (there are thousands of lines sent back) > > The problem I get is that expect seems to process this data in chunks. > For example, it will process: > > Protocol Address Age (min) Hardware Addr Type Interface > Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 > Internet XX.XX.97.28 171 XXXX.c5 > > where it will pull out the data correctly for the first line, but will > not match the second line since it is incomplete. Then, it processes > the next chunk. example: > > 25.d4c3 ARPA Vlan122 > Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 > > where it will not pull the data correctly for the first line > (incomplete), but will pull the correct data for the second line. > > I have used the TCL expect before and it does the same thing so I know > it is not a bug. I think there is just a gap in my understanding of > how expect processes the data that is sent back from spawned processes. > > Is there a way to make expect deal with all of the data as one big > chunk, rather than processing it in pieces? I hope someone can explain > how this works. If you "expect" some string or pattern that appears only after the desired output is complete, e.g., perhaps the command prompt "gw>", everything ought to be found in the before() method. -- Ken Irving |
From: Jason G. <JG...@cw...> - 2007-05-17 18:54:18
|
Hello, Here is the problem I am having: I use expect to spawn an SSH session to a cisco router and run the command = 'show arp', which sends a lot of data back. example: gw>show arp Protocol Address Age (min) Hardware Addr Type Interface Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 Internet XX.XX.97.28 171 XXXX.c525.d4c3 ARPA Vlan122 Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 ... (there are thousands of lines sent back) The problem I get is that expect seems to process this data in chunks. = For example, it will process: Protocol Address Age (min) Hardware Addr Type Interface Internet XX.XX.108.17 0 XXXX.319f.c3d9 ARPA Vlan133 Internet XX.XX.97.28 171 XXXX.c5 where it will pull out the data correctly for the first line, but will not = match the second line since it is incomplete. Then, it processes the next = chunk. example: 25.d4c3 ARPA Vlan122 Internet XX.XX.99.30 41 XXXX.420c.e73f ARPA Vlan124 where it will not pull the data correctly for the first line (incomplete), = but will pull the correct data for the second line. I have used the TCL expect before and it does the same thing so I know it = is not a bug. I think there is just a gap in my understanding of how = expect processes the data that is sent back from spawned processes. Is there a way to make expect deal with all of the data as one big chunk, = rather than processing it in pieces? I hope someone can explain how this = works. --Jason |
From: Wilbur J. <wr...@sa...> - 2007-05-09 12:41:22
|
Trapping prompts can be both tricky and deceiving when content is unreliable. It may not be necessary to match the whole prompt either, 'Q to quit' might be sufficient as long as you take any remaining characters into account later. -- Wilbur On 5/9/07 5:22 AM, "Roland Giersig" <rgi...@cp...> wrote: > My guess would be that the ^@ is actually a NUL byte. Have you tried > to match for a single char '.' instead? > > Roland > > On 4/24/07, Scotty74 <_si...@ya...> wrote: >> >> I've got a program that ssh's into a storage array and issues a query to get >> some information about devices. >> >> The command executes and displays some number of lines, and then depending >> on the number of device either gives back a prompt '# ' after displaying the >> devices, or prompts the user to hit a key with the following string: 'Press >> any key to continue (Q to quit)' >> >> I am never able to successfully match on the 'Press any key to continue (Q >> to quit)'... I never make it into that sub routine, and eventually fail. the >> log file shows a '^@ at the end of the Press any key string, I'm not sure >> why, but tried to match on it. Any suggestions would be appreciated. Thanks. >> >> here's a snippet: >> >> $ssh_exp->send("$command"); >> $ssh_exp->debug(3); >> $ssh_exp->expect( $GLOBAL_TIMEOUT , >> [ qr/Press any key to continue \(Q to quit\)\^\@$/ => sub >> { >> print("Got a press any key to continue\n"); >> my $fh = shift; >> #$ssh_exp->send("N"); >> $fh->send("BITEME\r"); >> exp_continue; >> } >> ] , >> [ '# $', >> sub { >> print("Got a prompt back\n"); >> } >> ] >> ); >> print("Sleeping\n"); >> sleep(5); >> >> >> here is the output which is logged to a file: >> >> # show disks encl >> Status Encl Slot Vendor Model Serial# >> Size(GB) >> ----------------------------------------------------------------------------->> - >> Up 0 0 ATA HDS725050KLA360 KRVN65ZAJAUR1F 500 >> Up 0 1 ATA HDS725050KLA360 KRVN65ZAJAY5HF 500 >> Up 0 2 ATA HDS725050KLA360 KRVN65ZAJAUSLF 500 >> Up 0 3 ATA HDS725050KLA360 KRVN65ZAJAV1LF 500 >> Up 0 4 ATA HDS725050KLA360 KRVN65ZAJAUUNF 500 >> Up 0 5 ATA HDS725050KLA360 KRVN65ZAJ9RH6F 500 >> Up 0 6 ATA HDS725050KLA360 KRVN65ZAJAV6YF 500 >> Up 0 7 ATA HDS725050KLA360 KRVN65ZAJAUUEF 500 >> Up 0 8 ATA HDS725050KLA360 KRVN65ZAJAT3ZF 500 >> Up 0 9 ATA HDS725050KLA360 KRVN65ZAJASBEF 500 >> Up 0 10 ATA HDS725050KLA360 KRVN65ZAJAV09F 500 >> Up 0 11 ATA HDS725050KLA360 KRVN65ZAJAY1WF 500 >> Up 1 0 ATA HDS725050KLA360 KRVN65ZAJARLWF 500 >> Up 1 1 ATA HDS725050KLA360 KRVN65ZAJAY06F 500 >> Up 1 2 ATA HDS725050KLA360 KRVN65ZAJAT8HF 500 >> Up 1 3 ATA HDS725050KLA360 KRVN65ZAJAY3DF 500 >> Up 1 4 ATA HDS725050KLA360 KRVN65ZAJAT04F 500 >> Up 1 5 ATA HDS725050KLA360 KRVN65ZAJAV4HF 500 >> Up 1 6 ATA HDS725050KLA360 KRVN65ZAJAT20F 500 >> Up 1 7 ATA HDS725050KLA360 KRVN65ZAJAY2HF 500 >> Up 1 8 ATA HDS725050KLA360 KRVN65ZAJASHXF 500 >> Press any key to continue (Q to quit)^@ >> -- >> View this message in context: >> http://www.nabble.com/problem-with-expect-pattern-match-tf3640813.html#a10168 >> 043 >> Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> Expectperl-discuss mailing list >> Exp...@li... >> https://lists.sourceforge.net/lists/listinfo/expectperl-discuss >> > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Adrian P. <ad...@ph...> - 2007-05-09 11:43:10
|
>>>>> "Sujai" == sujai <suj...@ta...> writes: Sujai> Hello ken., I want to execute multiple commands on the Sujai> ssh'ed machine.I want to execute iperf server. sujai I have a perl module that I never quite got around to CPANning (wasn't sure how to and never made time to figure it out) eventually named IPC::RemoteSession which allows one to run commands (and eval perl) on a remote connection (assuming ssh keys are setup correctly) :- $conn = IPC::RemoteSession (host => 'ahost'); $output = $conn->cmd ('a shell command'); $output = $conn->cmd ('another shell command'); my $result = $conn->perl ('some perl to eval'); Let me know if you'd like a copy. Sincerely, Adrian Phillips -- Who really wrote the works of William Shakespeare ? http://www.pbs.org/wgbh/pages/frontline/shakespeare/ |
From: Rui M. <rme...@te...> - 2007-05-09 11:23:59
|
Thanks for the advices given, but I managed to solve my problem! =20 I was doing everything right, and the way you told me. The problem was my prompt, in those LONG OUTPUT commands I gave (show running-config) there were certain characters that caused this regex to match: =20 my $prompt_default =3D "[\\\$%#>]\\s*(\\(enable\\)|)\\s*"; # A = strange prompt, but it=92s working fine (NO, IT WASN=92T !!!) (=85) qr/$prompt_default/, (=85) =20 I had this: $stdout =3D $exp->before() . $exp->match() . $exp->after(); match() was matching much earlier than I expected, and after() was the = one that was being truncated!!! =20 After some headaching troubleshooting, I found out that I simply needed = to change this line to make the match work where I intended it to work (at = the end): =20 qr/\n\S+$prompt_default$/, =20 =20 Now everything works fine! Thanks a lot. =20 =20 =20 _____ =20 From: exp...@li... [mailto:exp...@li...] On Behalf Of li...@jo... Sent: ter=E7a-feira, 8 de Maio de 2007 23:25 To: exp...@li... Subject: Re: [Expectperl-discuss] Output from before() gets truncated if = Re: Output from before() gets truncated if it's too long =20 Here's something that worked for me... 1. Expect on the system prompt ( qr/^REQ: / in my case) then send the command to print the listing 2. Optionally "expect" the command (to absorb it from the listing), you = can also absorb any headers you don't want.=20 3. Now let the system do its work. 4. Expect on another system prompt. Whatever printed in step 3 (i.e. from the system) is stored in $exp->before(), this is your listing. =20 Example: # Step 1: Get the system prompt and send a response... $exp->expect(10, [ qr/^REQ: / =3D> sub { $self =3D shift; $self->send("PRINT\r") } ], [ timeout =3D> sub { die ("Timeout in step 1") } ] ); # Step 2 not coded # Step 3: System prints stuff here # Step 4: Find the next system prompt $exp->expect(10, [ qr/^REQ: / ], [ timeout =3D> sub { die ("Timeout in step 4") } ] ); $listing =3D $exp->before(); print $listing; Regards, John. =20 =20 =20 |
From: Roland G. <rgi...@cp...> - 2007-05-09 11:22:45
|
My guess would be that the ^@ is actually a NUL byte. Have you tried to match for a single char '.' instead? Roland On 4/24/07, Scotty74 <_si...@ya...> wrote: > > I've got a program that ssh's into a storage array and issues a query to get > some information about devices. > > The command executes and displays some number of lines, and then depending > on the number of device either gives back a prompt '# ' after displaying the > devices, or prompts the user to hit a key with the following string: 'Press > any key to continue (Q to quit)' > > I am never able to successfully match on the 'Press any key to continue (Q > to quit)'... I never make it into that sub routine, and eventually fail. the > log file shows a '^@ at the end of the Press any key string, I'm not sure > why, but tried to match on it. Any suggestions would be appreciated. Thanks. > > here's a snippet: > > $ssh_exp->send("$command"); > $ssh_exp->debug(3); > $ssh_exp->expect( $GLOBAL_TIMEOUT , > [ qr/Press any key to continue \(Q to quit\)\^\@$/ => sub { > print("Got a press any key to continue\n"); > my $fh = shift; > #$ssh_exp->send("N"); > $fh->send("BITEME\r"); > exp_continue; > } > ] , > [ '# $', > sub { > print("Got a prompt back\n"); > } > ] > ); > print("Sleeping\n"); > sleep(5); > > > here is the output which is logged to a file: > > # show disks encl > Status Encl Slot Vendor Model Serial# > Size(GB) > ------------------------------------------------------------------------------ > Up 0 0 ATA HDS725050KLA360 KRVN65ZAJAUR1F 500 > Up 0 1 ATA HDS725050KLA360 KRVN65ZAJAY5HF 500 > Up 0 2 ATA HDS725050KLA360 KRVN65ZAJAUSLF 500 > Up 0 3 ATA HDS725050KLA360 KRVN65ZAJAV1LF 500 > Up 0 4 ATA HDS725050KLA360 KRVN65ZAJAUUNF 500 > Up 0 5 ATA HDS725050KLA360 KRVN65ZAJ9RH6F 500 > Up 0 6 ATA HDS725050KLA360 KRVN65ZAJAV6YF 500 > Up 0 7 ATA HDS725050KLA360 KRVN65ZAJAUUEF 500 > Up 0 8 ATA HDS725050KLA360 KRVN65ZAJAT3ZF 500 > Up 0 9 ATA HDS725050KLA360 KRVN65ZAJASBEF 500 > Up 0 10 ATA HDS725050KLA360 KRVN65ZAJAV09F 500 > Up 0 11 ATA HDS725050KLA360 KRVN65ZAJAY1WF 500 > Up 1 0 ATA HDS725050KLA360 KRVN65ZAJARLWF 500 > Up 1 1 ATA HDS725050KLA360 KRVN65ZAJAY06F 500 > Up 1 2 ATA HDS725050KLA360 KRVN65ZAJAT8HF 500 > Up 1 3 ATA HDS725050KLA360 KRVN65ZAJAY3DF 500 > Up 1 4 ATA HDS725050KLA360 KRVN65ZAJAT04F 500 > Up 1 5 ATA HDS725050KLA360 KRVN65ZAJAV4HF 500 > Up 1 6 ATA HDS725050KLA360 KRVN65ZAJAT20F 500 > Up 1 7 ATA HDS725050KLA360 KRVN65ZAJAY2HF 500 > Up 1 8 ATA HDS725050KLA360 KRVN65ZAJASHXF 500 > Press any key to continue (Q to quit)^@ > -- > View this message in context: http://www.nabble.com/problem-with-expect-pattern-match-tf3640813.html#a10168043 > Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Roland G. <rgi...@cp...> - 2007-05-09 11:20:40
|
Have you tried debugging it by setting $Expect::Exp_Internal =3D 1; ?? This will tell you exactly what strings get matched etc. Hope this helps, Roland On 5/8/07, Rui Meireles <rme...@te...> wrote: > > First of all, thanks for the quick answer. > > Quoting Ken Irving: > "If you can see the expected content in $stdout ..." > > But I can't see the expected result in $stdout. I can see the expected > result (all the way to the matched prompt) being printed to my screen, as > Expect prints all the outputs by default. > But I only get "Part1" of the output in $stdout (and, of course, in my > file). > > I'm using the standard Perl save-to-file mechanism: > > open(DEST, '>' . $filename); > flock(DEST, 2); > print DEST $stdout; > close DEST; > > > This only happens when the outputs are long (and it happens ALWAYS, and i= n > the same spot). > Do you have any idea of what this could be? > Thanks. > > > -----Original Message----- > From: exp...@li... > [mailto:exp...@li...] On Behalf Of Ke= n > Irving > Sent: ter=E7a-feira, 8 de Maio de 2007 18:13 > To: exp...@li... > Subject: Re: [Expectperl-discuss] Output from before() gets truncated ifi= t's > too long > > On Tue, May 08, 2007 at 02:45:00PM +0100, Rui Meireles wrote: > > Hi. I?m having a problem using Expect.pm > > > > I created a script to do automated ssh to several hosts. One thing I > > need to do is to enter several Cisco routers, execute the commands > > terminal length 0 and show running-config and save some of the output > > to a file. > > > > It?s all working fine, and as the commands are executed the correct > > output is automatically printed in the screen (expect.pm default > > option). However, when the output of the command is very long (show > > running-config) the output is not correctly stored in my variable > > $stdout, it?s always truncated in the same spot! > > > > Example: (These are parts of my code) > > ... > > $stdout =3D $exp->before() . $exp->match() . $exp->after(); > > ... > > > > print ?###############\n?; > > print ?$stdout\n?; > > print ?###############\n?; > > ... > > > > What happens is that when I print $stdout the output I get is: > > > > ############### > > (1st part of output) > > ############### > > (2nd part of output) > > > > And if I save $stdout to a file, only 1st part is saved (2nd part gets > > truncated). > > > > Does anyone know why this is happening? I tried putting some sleeps > > but that didn?t solve my problem. It almost seems that this works > > as some kind of buffer, that only when emptied can store more data! > > However, the qr/$prompt_default/ is working fine, as well as the > > automatic prints to the screen! > > If you can see the expected content in $stdout then this probably has > nothing to do with Expect.pm but rather with your perl coding. You > don't show how you're writing to a file. If you're open()ing > and print()ing to a filehandle, Perl tries very hard to flush buffers > when the script ends, even if you don't close() the filehandle, so > the results you describe are not likely. > > My guess is that you're redirecting output to a file, so it's not even > a perl problem but a shell or terminal issue. Maybe you can coerce the > buffer to flush by issuing a ^D or messing with the terminal settings > using stty, but the simplest fix is probably to do the write-to-file in > the perl script and let Perl handle it. > > Good luck! > > Ken > > -- > Ken Irving > Water and Environmental Research Center > University of Alaska, Fairbanks > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Roland G. <rgi...@cp...> - 2007-05-09 11:17:30
|
I dont know about iperf server but I would guess that it is not an interactive application and that you only want to execute some programs one after another, is this right? Then you could write a shell script and start that remotely via ssh. Roland On 5/9/07, sujai <suj...@ta...> wrote: > > Hello ken., > I want to execute multiple commands on the ssh'ed machine.I > want to execute iperf server. > sujai > > > Ken Irving wrote: > > > > On Tue, May 08, 2007 at 05:16:40PM +0530, Sujai Kumar wrote: > >> Hello everybody., > >> > >> I am new to expect. I want to execute some commands after SSH'ing > >> into a machine say 10.2.3.4. I have written script to automate ssh and > >> that is happening fine. After SSH'ed into the machine it exits from > >> the machine. How to execute a command in the SSH'ed machine. > > > > If all you want to do is issue commands, ssh is capable of doing that > > directly, e.g., (from a shell prompt): > > > > $ ssh 10.2.3.4 tail /var/log/syslog > > > > This can be automated by setting up key-based authentication and > > ssh-agent, e.g., using the keychain utility. > > > > IMHO Expect.pm and such are called for when you want to automate > > interactivity with the remote system, i.e., generate output commands > > based on the responses seen. > > > > Ken > > > > -- > > Ken Irving, fn...@ua..., 907-474-6152 > > Water and Environmental Research Center > > Institute of Northern Engineering > > University of Alaska, Fairbanks > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Expectperl-discuss mailing list > > Exp...@li... > > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > > > > > -- > View this message in context: http://www.nabble.com/query-tf3709123.html#a10390185 > Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: sujai <suj...@ta...> - 2007-05-09 08:17:11
|
Hello ken., I want to execute multiple commands on the ssh'ed machine.I want to execute iperf server. sujai Ken Irving wrote: > > On Tue, May 08, 2007 at 05:16:40PM +0530, Sujai Kumar wrote: >> Hello everybody., >> >> I am new to expect. I want to execute some commands after SSH'ing >> into a machine say 10.2.3.4. I have written script to automate ssh and >> that is happening fine. After SSH'ed into the machine it exits from >> the machine. How to execute a command in the SSH'ed machine. > > If all you want to do is issue commands, ssh is capable of doing that > directly, e.g., (from a shell prompt): > > $ ssh 10.2.3.4 tail /var/log/syslog > > This can be automated by setting up key-based authentication and > ssh-agent, e.g., using the keychain utility. > > IMHO Expect.pm and such are called for when you want to automate > interactivity with the remote system, i.e., generate output commands > based on the responses seen. > > Ken > > -- > Ken Irving, fn...@ua..., 907-474-6152 > Water and Environmental Research Center > Institute of Northern Engineering > University of Alaska, Fairbanks > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > -- View this message in context: http://www.nabble.com/query-tf3709123.html#a10390185 Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: <li...@jo...> - 2007-05-08 22:24:43
|
<p>Here's something that worked for me...</p><p>1. Expect on the system pro= mpt ( qr/^REQ: / in my case) then send the command to print the listing</p>= <p>2. Optionally "expect" the command (to absorb it from the list= ing), you can also absorb any headers you don't want. </p><p>3. Now le= t the system do its work.</p><p>4. Expect on another system prompt.</p><p>W= hatever printed in step 3 (i.e. from the system) is stored in $exp->befo= re(), this is your listing.</p><p> </p><p>Example:</p><p># Step 1: Get= the system prompt and send a response...<br />$exp->expect(10,<br />&nb= sp; [ qr/^REQ: / =3D> sub {<br /> &nb= sp; $self =3D shift;<br /> &= nbsp; $self->send("PRINT\r")<br /> &nbs= p; }<br /> ],<br /> [ timeout =3D> sub { die ("Timeout = in step 1") }<br /> ]<br />);<br /><br /># Step 2 not coded</p><= p># Step 3: System prints stuff here</p><p> # Step 4: Find the next sy= stem prompt<br />$exp->expect(10,<br />=0D [ qr/^REQ: / ],<br /> [ timeout =3D> sub { die ("Timeo= ut in step 4") } ]<br />=0D );</p><p>$listing =3D $exp->before();<br />print $listing;</p><p><br />R= egards,<br />John.</p><p> </p><p> </p><BR> |
From: Rui M. <rme...@te...> - 2007-05-08 18:59:33
|
First of all, thanks for the quick answer. Quoting Ken Irving: "If you can see the expected content in $stdout ..." But I can't see the expected result in $stdout. I can see the expected result (all the way to the matched prompt) being printed to my screen, = as Expect prints all the outputs by default. But I only get "Part1" of the output in $stdout (and, of course, in my file). I'm using the standard Perl save-to-file mechanism: open(DEST, '>' . $filename); flock(DEST, 2); print DEST $stdout; close DEST; This only happens when the outputs are long (and it happens ALWAYS, and = in the same spot). Do you have any idea of what this could be? Thanks. -----Original Message----- From: exp...@li... [mailto:exp...@li...] On Behalf Of = Ken Irving Sent: ter=E7a-feira, 8 de Maio de 2007 18:13 To: exp...@li... Subject: Re: [Expectperl-discuss] Output from before() gets truncated = ifit's too long On Tue, May 08, 2007 at 02:45:00PM +0100, Rui Meireles wrote: > Hi. I?m having a problem using Expect.pm >=20 > I created a script to do automated ssh to several hosts. One thing I > need to do is to enter several Cisco routers, execute the commands > terminal length 0 and show running-config and save some of the output > to a file. > > It?s all working fine, and as the commands are executed the correct > output is automatically printed in the screen (expect.pm default > option). However, when the output of the command is very long (show > running-config) the output is not correctly stored in my variable > $stdout, it?s always truncated in the same spot! >=20 > Example: (These are parts of my code) > ... > $stdout =3D $exp->before() . $exp->match() . $exp->after(); > ... >=20 > print ?###############\n?; > print ?$stdout\n?; > print ?###############\n?; > ...=20 > > What happens is that when I print $stdout the output I get is: >=20 > ############### > (1st part of output) > ############### > (2nd part of output) >=20 > And if I save $stdout to a file, only 1st part is saved (2nd part gets > truncated). > > Does anyone know why this is happening? I tried putting some sleeps > but that didn?t solve my problem. It almost seems that this works > as some kind of buffer, that only when emptied can store more data! > However, the qr/$prompt_default/ is working fine, as well as the > automatic prints to the screen! If you can see the expected content in $stdout then this probably has nothing to do with Expect.pm but rather with your perl coding. You=20 don't show how you're writing to a file. If you're open()ing and print()ing to a filehandle, Perl tries very hard to flush buffers when the script ends, even if you don't close() the filehandle, so the results you describe are not likely. My guess is that you're redirecting output to a file, so it's not even=20 a perl problem but a shell or terminal issue. Maybe you can coerce the buffer to flush by issuing a ^D or messing with the terminal settings=20 using stty, but the simplest fix is probably to do the write-to-file in the perl script and let Perl handle it. Good luck! Ken --=20 Ken Irving Water and Environmental Research Center University of Alaska, Fairbanks -------------------------------------------------------------------------= This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Ken I. <fn...@ua...> - 2007-05-08 17:24:26
|
On Tue, May 08, 2007 at 05:16:40PM +0530, Sujai Kumar wrote: > Hello everybody., > > I am new to expect. I want to execute some commands after SSH'ing > into a machine say 10.2.3.4. I have written script to automate ssh and > that is happening fine. After SSH'ed into the machine it exits from > the machine. How to execute a command in the SSH'ed machine. If all you want to do is issue commands, ssh is capable of doing that directly, e.g., (from a shell prompt): $ ssh 10.2.3.4 tail /var/log/syslog This can be automated by setting up key-based authentication and ssh-agent, e.g., using the keychain utility. IMHO Expect.pm and such are called for when you want to automate interactivity with the remote system, i.e., generate output commands based on the responses seen. Ken -- Ken Irving, fn...@ua..., 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks |
From: Ken I. <fn...@ua...> - 2007-05-08 17:12:56
|
On Tue, May 08, 2007 at 02:45:00PM +0100, Rui Meireles wrote: > Hi. I?m having a problem using Expect.pm > > I created a script to do automated ssh to several hosts. One thing I > need to do is to enter several Cisco routers, execute the commands > terminal length 0 and show running-config and save some of the output > to a file. > > It?s all working fine, and as the commands are executed the correct > output is automatically printed in the screen (expect.pm default > option). However, when the output of the command is very long (show > running-config) the output is not correctly stored in my variable > $stdout, it?s always truncated in the same spot! > > Example: (These are parts of my code) > ... > $stdout = $exp->before() . $exp->match() . $exp->after(); > ... > > print ?###############\n?; > print ?$stdout\n?; > print ?###############\n?; > ... > > What happens is that when I print $stdout the output I get is: > > ############### > (1st part of output) > ############### > (2nd part of output) > > And if I save $stdout to a file, only 1st part is saved (2nd part gets > truncated). > > Does anyone know why this is happening? I tried putting some sleeps > but that didn?t solve my problem. It almost seems that this works > as some kind of buffer, that only when emptied can store more data! > However, the qr/$prompt_default/ is working fine, as well as the > automatic prints to the screen! If you can see the expected content in $stdout then this probably has nothing to do with Expect.pm but rather with your perl coding. You don't show how you're writing to a file. If you're open()ing and print()ing to a filehandle, Perl tries very hard to flush buffers when the script ends, even if you don't close() the filehandle, so the results you describe are not likely. My guess is that you're redirecting output to a file, so it's not even a perl problem but a shell or terminal issue. Maybe you can coerce the buffer to flush by issuing a ^D or messing with the terminal settings using stty, but the simplest fix is probably to do the write-to-file in the perl script and let Perl handle it. Good luck! Ken -- Ken Irving Water and Environmental Research Center University of Alaska, Fairbanks |
From: Jason G. <JG...@cw...> - 2007-05-08 15:14:15
|
I just made the switch to expect.pm also, so this is fresh in my mind. I = use " $var =3D ($exp->matchlist)[0] " for the first matched item. Make = sure you use the parenthesis exactly as listed or it will not work. --Jason >>> <sp...@nc...> 4/24/2007 6:35 PM >>> Hello all, I've used the "real" expect for a number of years, and now find myself having to do some stuff w/ perl-expect. Is there a way to capture text w/ () in the expect of perl like you can w/ expect? For example the following bit of expect code will grab the hostname of the device you've logged into and store it in a variable called hostname: expect { -re "\n+(.*}>" } set hostname $expect_out(1,string) The $expect_out(1,string) grabs what is inside the () in the expect statement. Like a backrefrence \1 in a regexp. Is there a way to do the same thing w/ perl expect? Thanks in advance. Sean ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/=20 _______________________________________________ Expectperl-discuss mailing list Exp...@li...=20 https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Rui M. <rme...@te...> - 2007-05-08 13:45:09
|
Hi. I'm having a problem using Expect.pm I created a script to do automated ssh to several hosts. One thing I need to do is to enter several Cisco routers, execute the commands terminal length 0 and show running-config and save some of the output to a file. It's all working fine, and as the commands are executed the correct output is automatically printed in the screen (expect.pm default option). However, when the output of the command is very long (show running-config) the output is not correctly stored in my variable $stdout, it's always truncated in the same spot! Example: (These are parts of my code) #--------------------------------------------------------------------------- ------------------------ my $exp; my $prompt_default = "[\\\$%#>]\\s*(\\(enable\\)|)\\s*"; # A strange prompt, but it's working fine $exp = Expect->spawn("ssh ${username}\@${host}") or die "ERROR: Couldn't spawn ssh connection, $!\n"; $exp->log_file($opts{'l'}); $exp->restart_timeout_upon_receive(1); $exp->max_accum(0); # Executing Login - all is made correctly # (.) # Executing commands # (.) # Retrieving Output $exp->clear_accum(); $exp->expect($timeout, [ qr/$prompt_default/, sub { my $fh = shift; $stdout = $exp->before() . $exp->match() . $exp->after(); print $fh "\n"; #exp_continue; # Don't continue } ] ) or do{ erro("Invalid Prompt, " . $exp->exp_error() . "\n"); $exp->soft_close(); return; }; print "###############\n"; print "$stdout\n"; print "###############\n"; #--------------------------------------------------------------------------- ------------------------ What happens is that when I print $stdout the output I get is: ############### (1st part of output) ############### (2nd part of output) And if I save $stdout to a file, only 1st part is saved (2nd part gets truncated). Does anyone know why this is happening? I tried putting some sleeps but that didn't solve my problem. It almost seems that this works as some kind of buffer, that only when emptied can store more data! However, the qr/$prompt_default/ is working fine, as well as the automatic prints to the screen! Thanks in advance. |
From: Roland G. <rgi...@cp...> - 2007-05-08 13:00:54
|
Yes there is. Read the perldoc Expect and look for "matchlist()"... Hope this helps, Roland On 4/25/07, sp...@nc... <sp...@nc...> wrote: > Hello all, > > I've used the "real" expect for a number of years, and now find myself > having to do some stuff w/ perl-expect. > > Is there a way to capture text w/ () in the expect of perl like you can > w/ expect? > > For example the following bit of expect code will grab the hostname of > the device you've logged into and store it in a variable called hostname: > expect { > -re "\n+(.*}>" > } > set hostname $expect_out(1,string) > > The $expect_out(1,string) grabs what is inside the () in the expect > statement. Like a backrefrence \1 in a regexp. > > Is there a way to do the same thing w/ perl expect? > > Thanks in advance. > Sean > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Sujai K. <suj...@ta...> - 2007-05-08 11:45:17
|
Hello everybody., I am new to expect. I want to execute some commands after SSH'ing into a machine say 10.2.3.4. I have written script to automate ssh and that is happening fine. After SSH'ed into the machine it exits from the machine. How to execute a command in the SSH'ed machine. Thanks and Regards., Sujai. |