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: sumncguy <sum...@ya...> - 2008-02-06 14:02:41
|
I did search the forum first, found the snippet described but it still doesnt work. Heres the execution on a Solaris box. ~> mssh 10.10.10.10 Attempting to connect ... 10.10.10.10 Switching to enable... somerouter#BAIL! % Unknown command or computer name, or unable to find computer address somerouter#exit Connection to 10.10.10.10 closed. Here is the code Im using for this particular function. # $process->interact([$in_handle],[$escape sequence]) # $exp->interact(\*STDIN, 'BAIL!'); $child->interact(\*STDIN, 'BAIL!'); $child->send("show clock\n"); $child->expect(10,"#"); I appreciate all the help !! Chris Ken Irving wrote: > > On Mon, Feb 04, 2008 at 07:21:25PM -0800, sumncguy wrote: >> >> After racking my brains for a few weeks, I found that >> >> Expects interact will hold and continue / return based on user input. Im >> now >> trying to accomplish that with the Perl Expect.pm module. It says ... >> # $process->interact([$in_handle],[$escape sequence]) >> >> $child->interact(); >> >> $child->interact(STDIN,'X'); >> $child->interact([STDIN],['X']); >> $child->interact( ,'X'); obviously not >> $child->interact('X'); here too .. >> >> also tried all the above with dub quotes. >> .... must be missing something. >> >> In expect >> >> interact "X" return >> >> Stops, give the user a router (for example) prompt back. When he/she hits >> X, >> the expect script continues. > > You didn't hit upon the necessary syntax for passing a filehandle, e.g.: > > $ grep BAIL src/perl/radio-server.pl > $exp->interact(\*STDIN, 'BAIL!'); > > The form \*STDIN is a reference to a typeglob, and is necessary to pass > the filehandle as an argument. > > Ken > > -- > Ken Irving, fn...@ua... > Water and Environmental Research Center > Institute of Northern Engineering > University of Alaska, Fairbanks > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > -- View this message in context: http://www.nabble.com/Holding-perl-expect-until-user-ready-..-tp15282716p15306656.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Roland G. <rgi...@cp...> - 2008-02-06 13:48:05
|
Can you post the relevant parts of the script? PTY-handling is hard, that's why IO::Tty is doing it in C. And you have no way of installing IO::Tty locally? If you worry about distribution, have a look at PAR, the Perl Archiver, on CPAN which lets you package required modules, even binary ones, with your script. Servus, Roland Carlyle Sutphen wrote: > Hello, > > I am a system administrator in a large corporation which > has not included Expect.pm and its siblings IO::Tty and IO::Stty > in the packaging. > > I have written a perl script which creates a terminal for a child > process which uses the terminal rather than standard IO; > much as expect does but very simply and of very limited > scope. > > This script works fine on AIX but not on SunOS or Linux. > > I need to know how to get the name of the slave side after > opening the control side (/dev/ptc on AIX and /dev/ptmx on > the others). On AIX ttyname does this for me but it returns > "Inappropriate ioctl for device" elsewhere. > > I don't mean to take up time and space on this list but I have been > looking unsuccessfully for a suitable mailing list more suited to > my problem. > > Thank you for any pointers. > > Best regards, > Carlyle > -- > > Informationen (einschließlich Pflichtangaben) zu einzelnen, innerhalb der EU tätigen Gesellschaften und Zweigniederlassungen des Konzerns Deutsche Bank finden Sie unter http://www.db.com/de/content/pflichtangaben.htm. Diese E-Mail enthält vertrauliche und/ oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet. > > Please refer to http://www.db.com/en/content/eu_disclosures.htm for information (including mandatory corporate particulars) on selected Deutsche Bank branches and group companies registered or incorporated in the European Union. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Carlyle S. <car...@db...> - 2008-02-06 12:58:39
|
Hello, I am a system administrator in a large corporation which has not included Expect.pm and its siblings IO::Tty and IO::Stty in the packaging. I have written a perl script which creates a terminal for a child process which uses the terminal rather than standard IO; much as expect does but very simply and of very limited scope. This script works fine on AIX but not on SunOS or Linux. I need to know how to get the name of the slave side after opening the control side (/dev/ptc on AIX and /dev/ptmx on the others). On AIX ttyname does this for me but it returns "Inappropriate ioctl for device" elsewhere. I don't mean to take up time and space on this list but I have been looking unsuccessfully for a suitable mailing list more suited to my problem. Thank you for any pointers. Best regards, Carlyle -- Informationen (einschließlich Pflichtangaben) zu einzelnen, innerhalb der EU tätigen Gesellschaften und Zweigniederlassungen des Konzerns Deutsche Bank finden Sie unter http://www.db.com/de/content/pflichtangaben.htm. Diese E-Mail enthält vertrauliche und/ oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet. Please refer to http://www.db.com/en/content/eu_disclosures.htm for information (including mandatory corporate particulars) on selected Deutsche Bank branches and group companies registered or incorporated in the European Union. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. |
From: Ken I. <fn...@ua...> - 2008-02-05 17:35:03
|
On Mon, Feb 04, 2008 at 07:21:25PM -0800, sumncguy wrote: > > After racking my brains for a few weeks, I found that > > Expects interact will hold and continue / return based on user input. Im now > trying to accomplish that with the Perl Expect.pm module. It says ... > # $process->interact([$in_handle],[$escape sequence]) > > $child->interact(); > > $child->interact(STDIN,'X'); > $child->interact([STDIN],['X']); > $child->interact( ,'X'); obviously not > $child->interact('X'); here too .. > > also tried all the above with dub quotes. > .... must be missing something. > > In expect > > interact "X" return > > Stops, give the user a router (for example) prompt back. When he/she hits X, > the expect script continues. You didn't hit upon the necessary syntax for passing a filehandle, e.g.: $ grep BAIL src/perl/radio-server.pl $exp->interact(\*STDIN, 'BAIL!'); The form \*STDIN is a reference to a typeglob, and is necessary to pass the filehandle as an argument. Ken -- Ken Irving, fn...@ua... Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks |
From: sumncguy <sum...@ya...> - 2008-02-05 03:21:28
|
After racking my brains for a few weeks, I found that Expects interact will hold and continue / return based on user input. Im now trying to accomplish that with the Perl Expect.pm module. It says ... # $process->interact([$in_handle],[$escape sequence]) $child->interact(); $child->interact(STDIN,'X'); $child->interact([STDIN],['X']); $child->interact( ,'X'); obviously not $child->interact('X'); here too .. also tried all the above with dub quotes. .... must be missing something. In expect interact "X" return Stops, give the user a router (for example) prompt back. When he/she hits X, the expect script continues. Thanks in advance. -- View this message in context: http://www.nabble.com/Holding-perl-expect-until-user-ready-..-tp15282716p15282716.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Juan P. F. G. <jfe...@gm...> - 2008-01-29 01:08:24
|
This works for me, hope it helps... sub verificaprompt { print "Verificando prompt...\n"; $actualprompt=''; $rootexpect->send("\n"); my $shpromvrfy = $rootexpect->expect(750,'#','>','$'); my $match=$rootexpect->match(); my @outp = split /\n/, $rootexpect->exp_before(); $actualprompt= "$outp[$#outp]"."$match"; print "got $actualprompt\n"; } |
From: Matt Z. <mzagrabe@d.umn.edu> - 2008-01-28 23:15:26
|
Greetings, First, you should not start a new thread by replying to another and changing the subject. On Mon, 2008-01-28 at 10:52 -0600, ESRY, DONALD H, JR. (DON), ATTGNS wrote: > Hi All, >=20 > I want to login to a bunch of routers and log the output of some show > commands. Is there a way to prepend each line of output with the router > name? >=20 > I'm using:=20 > $exp->log_file($outfile); >=20 > Is there a way to tell log_file to start each line with some defined > text? Is there an alternative? Instead of logging to a file, log to a subroutine and have the subroutine prepend specific output as desired. $exp->log_file(\log_expect); sub log_expect { my $match =3D shift; $match =3D~ s/^/router-name/; print FILE $match; } * This is all from memory and guessing. Use at your own risk. Cheers, --=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: bkincer <dev...@gm...> - 2008-01-28 17:26:17
|
bkincer wrote: > > Hello all, > > I've been banging my head against this problem for a while now and wanted > to see if anyone else has any ideas. Any help would be greatly > appreciated. > > So, the problem is this... I'm using the expect module to log into a list > of servers, then run through a list of commands. I have a problem > expecting the first prompt when I get logged in. And it's only on one > certain type of prompt. Due to being such a huge environment, the only > thing I can consistently expect in my prompt is my username. > > If the prompt is this: "username@machine:~> " > It won't match the username for some reason. I thought it could be "@" > sign, but if i set my prompt to duplicate itself, it matches. ie, > "username@machine:~> username@machine:~> " > > I've tried setting the raw_pty(1) to no avail. > > FYI, all these machines I am running this on/against are Linux machines. > > Thank you in advance for any help. > SOLVED!!!! Ok, sorry to waste everyone's time. I turned on debugging found out exactly what was "wrong". I found it was matching on the first prompt. However, when I matched my code was calling a subroutine, which then again tried to expect my username. Herein lies the problem... I was not aware expect throws out your previously matched string, and only tries to match on your "after string" (which is why my subroutine matched when I repeated the same prompt twice in my PS1 variable, the username was then in my "after string"). I edited my subroutine to send a carriage return upon being, then the next expect works beautifully like it should! -- View this message in context: http://www.nabble.com/problems-matching-first-prompt-upon-ssh-login-tp15136496p15140175.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: ESRY, D. H, J. (DON), A. <de...@at...> - 2008-01-28 16:52:28
|
Hi All, I want to login to a bunch of routers and log the output of some show commands. Is there a way to prepend each line of output with the router name? I'm using:=20 $exp->log_file($outfile); Is there a way to tell log_file to start each line with some defined text? Is there an alternative? Thanks, Don =20 |
From: bkincer <dev...@gm...> - 2008-01-28 15:00:19
|
Hello all, I've been banging my head against this problem for a while now and wanted to see if anyone else has any ideas. Any help would be greatly appreciated. So, the problem is this... I'm using the expect module to log into a list of servers, then run through a list of commands. I have a problem expecting the first prompt when I get logged in. And it's only on one certain type of prompt. Due to being such a huge environment, the only thing I can consistently expect in my prompt is my username. If the prompt is this: "username@machine:~> " It won't match the username for some reason. I thought it could be "@" sign, but if i set my prompt to duplicate itself, it matches. ie, "username@machine:~> username@machine:~> " I've tried setting the raw_pty(1) to no avail. FYI, all these machines I am running this on/against are Linux machines. Thank you in advance for any help. -- View this message in context: http://www.nabble.com/problems-matching-first-prompt-upon-ssh-login-tp15136496p15136496.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Frank S. <fr...@sc...> - 2008-01-28 11:45:44
|
hi, i tried a little script, which works well on Cisco Routers ####################################################################### my $telnet =3D3D Net::Telnet->new(Host=3D3D>${routername}); my ${ExpectObject}=3D3DExpect->exp_init($telnet); ${ExpectObject}->debug(1); ${ExpectObject}->log_file("/tmp/test.log"); ${ExpectObject}->expect( ${timeout}, [qr/(username|login): /i, sub { my $exp=3D3Dshift; $exp->send("${username}\n"); exp_continue; } ], [qr/password: /i, sub { my $exp=3D3Dshift; $exp->send("${password}\n"); exp_continue; } ], '-re',qr/[^\n]*(>|#)[\ \t]*/ ); ${ExpectObject}->send("exit"); ######################################################################## but if i try it on a juniper router, the only output i get in /tmp/test.log looks like that: =FF=FD^X=FF=FD =FF=FD#=FF=FD'=FF=FD$ in hex: root@nvm1:/tmp# od -x /tmp/test.log 0000000 fdff ff18 20fd fdff ff23 27fd fdff 0024 0000017 root@nvm1:/tmp# NB: I would like to use net::telnet, because (IMHO) the error handling with spawn(telnet) is awful. The combination expect->spawn->telnet works well except error handling and net::telnet ("standalone") also works well, but i have already a bunch of modules based on Expect.pm which i don`t want to rewrite. This is why i would prefer the combination of Expect and Net::Telnet. Any thoughts? greets M0ses |
From: <BI...@sc...> - 2008-01-24 18:41:53
|
Hello readers, I am working on a project for automating certain sftp file transfers, that will use Net::SFTP::Foreign and the login part will be taken care of by Expect. In order to see what is going on I would like to use the -v option of ssh to get some debug information. Now the problem is that the debug information from ssh (coming on ssh's stderr) is mixed with the information coming from sftp (coming on ssh's stdout) I use code like use Expect; my $conn = Expect->new; $conn->raw_pty(1); $conn->log_user(0); my $ok = $conn->spawn('ssh', '-v', 'user@host', '-s', 'sftp'); # rest of code omitted In this case the program crashes, because the debug information from ssh interferes with the communication protocol for sftp login. When the '-v' option for ssh is not given, the program runs fine, but I don't get debug info from ssh (as could be, hm, expected). Is it possible to have Expect transparently forward the info on ssh's stderr and use stdout for communication? That is, keep stderr and stdout from the spawn program in separate readable streams? Looking forward for response, Bert |
From: prem s. <pre...@ya...> - 2008-01-03 18:34:23
|
Hi Matt, Thats great... It worked for me !!! ~Prem Matt Zagrabelny <mzagrabe@d.umn.edu> wrote: On Thu, 2008-01-03 at 03:59 -0800, Prem Sangeeth wrote: > I am using a sub routine of expect to be called in by all my testcases. > For that, I am planning to send the arguments and based upon the arguments > it should expect. > > proc exp { > > my @val1 = "@_[0]"; > my $val2 = "@_[1]"; > my $val3 = "@_[2]"; > > my $exp = Expect->spawn(@_[0]); > $exp->log_file("buffer.txt", "w"); > > $exp->expect(10000, > [ qr'"$val2"', <<<< even though $val2 has that value, here > its breaking I would try: qr/$val2/ which has worked for me. -- 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 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss --------------------------------- Sent from Yahoo! - a smarter inbox. |
From: Matt Z. <mzagrabe@d.umn.edu> - 2008-01-03 13:15:26
|
On Thu, 2008-01-03 at 03:59 -0800, Prem Sangeeth wrote:=20 > I am using a sub routine of expect to be called in by all my testcases. > For that, I am planning to send the arguments and based upon the argument= s > it should expect. >=20 > proc exp { >=20 > my @val1 =3D "@_[0]"; > my $val2 =3D "@_[1]"; > my $val3 =3D "@_[2]"; >=20 > my $exp =3D Expect->spawn(@_[0]); > $exp->log_file("buffer.txt", "w"); >=20 > $exp->expect(10000, > [ qr'"$val2"', <<<< even though $val2 has that value, h= ere > its breaking I would try: qr/$val2/ which has worked for me. --=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: Prem S. <pre...@ya...> - 2008-01-03 11:59:52
|
I am using a sub routine of expect to be called in by all my testcases. For that, I am planning to send the arguments and based upon the arguments it should expect. proc exp { my @val1 = "@_[0]"; my $val2 = "@_[1]"; my $val3 = "@_[2]"; my $exp = Expect->spawn(@_[0]); $exp->log_file("buffer.txt", "w"); $exp->expect(10000, [ qr'"$val2"', <<<< even though $val2 has that value, here its breaking sub { print "the values are $val1[0],$val2,$val3"; $spawn_ok = 1; my $fh = shift; $fh->send("@_[2]\n"); $fh->send("exit\n"); exp_continue; } ], ); $exppat = "^Enter"; &initexpect($cmd,$exppat,vt100); The problem which I face is whenever I try to substitue a special character within qr, it fails... Any thoughts of how to rectify this problem -- View this message in context: http://www.nabble.com/How-to-substitue-a-value-within-the-expect-qr%27%24val%27-%3C%3C%3C-not-working-tp14595730p14595730.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Prem S. <pre...@ya...> - 2007-12-31 09:13:10
|
Hi, I am trying to spawn commands using the same exp object and getting the following error. My testing involves execution of a unix based command and then based on the O/p, I need to send in values. Right now, I need to create 45 objects for executing 45 such commands. Let me know is it a limitation or I am misssing smethg here ? Cannot reuse an object with an already spawned command at expectproblem.pl line 32 Code : $exp->spawn($cmd); $exp->expect(10000, [ qr'^Dialing', sub { $spawn_ok = 1; my $fh = shift; $fh->send("\c\\n"); exp_continue; } ], ); $exp->spawn($cmd); <<<< This throws out the error due to the same obj usage ... $exp->expect(10000, [ qr'^Dialing', sub { $spawn_ok = 1; my $fh = shift; $fh->send("\c\\n"); exp_continue; } ], ); -- View this message in context: http://www.nabble.com/Do-I-need-to-specify-unquie-expect-obj-for-each-spawn-command---tp14555577p14555577.html Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Amarnath M. M. <m_a...@ho...> - 2007-12-19 07:05:18
|
Hi, Hope below script helps. #!/usr/local/bin/perl use Expect; my $obj =3D new Expect->spawn(ssh, @params); my $prompt =3D "#"; my $timeout =3D 10; print $ARGV[0],"\n"; my $passwd =3D " "; # define ur passwd here my @params =3D qw( -l root); push(@params,$ARGV[0]); my $obj =3D new Expect->spawn(ssh, @params); $obj->expect($timeout, [ qr/username: /i, sub { $obj->send("root\r\n"); exp_continue;}], [ qr/\(yes\/no\)/i, sub { $obj->send("yes\r\n"); exp_continue;}], [ qr/password:/i, sub { $obj->send("$passwd\r\n"); } ]); $obj->send("\r\n"); $obj->expect($timeout, '-re' , $prompt, sub { $obj->send("PS1=3D# \r\n"); }); #sets the Pr= imary Prompt #print $obj->exp_command()," \n"; $obj->expect($timeout, '-re',$prompt, sub { $obj->send("echo -e \"##\\t##\" \r\n")= ; }); # for tab $obj->expect($timeout, '-re', $prompt, sub { $obj->send("\^B\r\n") }); #type <Ctrl= -V followed by CTRL-B my $input =3D <STDIN>; chomp($input); $obj->expect($timeout, '-re', $prompt, sub { $obj->send("$input\r\n") }); #sending= keyboard input. $obj->interact(); Date: Tue, 18 Dec 2007 16:35:43 +0530 From: pre...@gm... To: exp...@li... Subject: [Expectperl-discuss] Need to know about send command of Expect pac= kage.Very urgent!!!! HI All, =20 I am currently working on one command line application on AIX (Unix Platfor= m).Here i need to use Expect package. By using Expect package at the top of the script,i want to use just Send co= mmand of Expect package to send characters like, =20 1. Press Enter key 2. Press spacebar 3. Press Control B or Control x 4. Or it could be just type character from keyboard through my perl script = in the application. =20 Please let me know how can i use send command for above mentioned functiona= lities.I need this information ASAP. =20 Any help is much appreciated. =20 Thanks & Regards, Preeti _________________________________________________________________ Post free property ads on Yello Classifieds now! www.yello.in http://ss1.richmedia.in/recurl.asp?pid=3D220= |
From: Preeti B <pre...@gm...> - 2007-12-18 11:05:49
|
HI All, I am currently working on one command line application on AIX (Unix Platform).Here i need to use Expect package. By using Expect package at the top of the script,i want to use just Send command of Expect package to send characters like, 1. Press Enter key 2. Press spacebar 3. Press Control B or Control x 4. Or it could be just type character from keyboard through my perl script in the application. Please let me know how can i use send command for above mentioned functionalities.I need this information ASAP. Any help is much appreciated. Thanks & Regards, Preeti |
From: Juan P. F. G. <jfe...@gm...> - 2007-12-14 00:59:46
|
> > configurationFile =3D=3D> PerlScript <=3D=3D> InstallerProgram > > Script: [Name: telnet.pl] > --------------------------- > #!/usr/local/bin/perl > > use Expect; > use Net::Telnet; > > $prompt =3D '/[\]%>#\$]\s$/i'; > > $telnetObj =3D new Net::Telnet ( Timeout =3D> 20, Prompt =3D> $prompt); > $telnetObj->open ('host1'); > > $telnet =3D Expect->exp_init ($telnetObj); > $telnet->log_stdout (1); > > $telnet->expect (20, 'login: '); > $telnet->send ("user\r"); > $telnet->expect (20, 'Password: '); > $telnet->send ("password\r"); > > $telnet->expect (20, -re, $prompt); > $telnet->send ("id\r"); > $telnet->expect (20, -re, $prompt); > $telnet->send ("ls -ltr\r"); > > $telnet->hard_close(); > > ## END OF SCRIPT ## > > > Output: > --------------------------- > # ./telnet.pl > =FF=FD% > # > --------------------------- try using a 'spawn' to lunch the connection... my $command=3D"telnet x.x.x.x"; # or pass the host at @params array $rootexpect=3DExpect->spawn($command, @params) or die "$command: $! FALLO\n= "; Then add some debug with expect internal to get an idea where the script is stuck.. $rootexpect->exp_internal('1'); Hope it helps Good luck |
From: deepblue <rak...@ya...> - 2007-12-11 14:25:13
|
Hi all, I am working on a project that would automate the installation of product o= n remote machine(s). I have a Perl-Expect script ready that would send answers to the questions asked by the InstallerProgram and thus drive the InstallerProgram independently without the interaction of user. Pictiorally: configurationFile =3D=3D> PerlScript <=3D=3D> InstallerProgram This PerlScript would read the configurationFile and talk with the InstallerProgram and provide the answers to the questions the InstallerProgram asks. I need this to run this PerlScript from host1 onto host2, host3 ... so that the product is installed on host2, host3 ... For this, I am using Net::Telnet to connect to the host then using Expect's exp_init() to convert this telnet handle to expect's handle. However I coul= d not get this working. Below is the script along with the output. Script: [Name: telnet.pl] --------------------------- #!/usr/local/bin/perl use Expect; use Net::Telnet; $prompt =3D '/[\]%>#\$]\s$/i'; $telnetObj =3D new Net::Telnet ( Timeout =3D> 20, Prompt =3D> $prompt); $telnetObj->open ('host1'); $telnet =3D Expect->exp_init ($telnetObj); $telnet->log_stdout (1); $telnet->expect (20, 'login: '); $telnet->send ("user\r"); $telnet->expect (20, 'Password: '); $telnet->send ("password\r"); $telnet->expect (20, -re, $prompt); $telnet->send ("id\r"); $telnet->expect (20, -re, $prompt); $telnet->send ("ls -ltr\r"); $telnet->hard_close(); ## END OF SCRIPT ## Output: --------------------------- # ./telnet.pl =C3=BF=C3=BD% # --------------------------- It shows the above output and stops there until timeout occurs. I also tried this using: (1) IO::Socket::INET (2) IO::Socket::Telnet, however I could not make it work for me. I am using - 1. SUN Solaris 10, 2. Perl 5.8.8 3. Expect 1.21 Is there a better way of making this work (using some other module?). One NOTE: I have contents of the .rhosts file as: + + so that root can directly execute commands using rsh and but cannot login t= o the system (using rlogin/ssh)as /etc/default/login has the CONSOLE paramete= r enabled (i.e., it is NOT commented out). Also I dont want to have the passwords stored somewhere.. This would be a overhead since each time the root password is changed, I need to change the file storing passwords. Could any of you please help me on this ? Regards, ~DeepBlue --=20 View this message in context: http://www.nabble.com/Please-Help-me-with-Exp= ect-and-Net%3A%3ATelnet-or-IO%3A%3ASocket%3A%3ATelnet-tp14274995p14274995.h= tml Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |
From: Roland G. <rgi...@cp...> - 2007-11-21 17:08:36
|
Why don't you just write a shell script that groups the remote commands and also checks their exit states and then directly call that script with 'ssh remote-script.sh'? Alternatively you could execute those commands one by one using only ssh, because ssh will report the exit status back to you... $ ssh user@host "exit 78"; echo $? 78 Expect is only for "curing those uncontrollable fits of interaction". as Don Libes has put it. If you can manage without, do so. Hope this helps, Roland praveen mall wrote: > Hi Guys, > > I have problem with executing the remote command , like mkdir , chmod > etc... . If they are executed successfully they doesn't return > anything. I need someway to verify that they got executed > successfully. > Is there any idea? > > Second problem I have is that I am executing the remote command , > first I make the ssh connection then I send the command one by one. > Problem is that when will I get to particular command is get finished. > because I guess slave system is not returning the EOF as that is > closing the stdout may be stdin also. I did something like that... > > $exp->("commad;echo command finished"); > > and I expect the "command finished". $exp->expect("600","command > finished"); Here I am hardcoding the 600 seconds to wait for that. If > any script/command takes more than 600 seconds then obiviously > it will fail. I want to wait for forever until I get the "command > finished". Please don't tell me to do the $exp->expect(undef) because > I am not able to receive the EOF from slave system. I do not want to > put any > time limitation like 600 seconds. I want it should wait for forever > for "command finished" not for EOF. > > I read all the tutorial what I get is: > ou are probably on one of the systems where the master doesn't get an > EOF when the slave closes stdin/out/err. > One possible solution is when you spawn a process, follow it with a > unique string that would indicate the process is finished. > $process = Expect->spawn('telnet somehost; echo ____END____'); > > And then $process->expect($timeout,'____END____','other','patterns'); > > I did not get this line what the 'other' and 'pattern' mean over here. > > If anyone is able to solve this problem really that will be better for me. > > Thanks, > Praveen Mall > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: praveen m. <mal...@gm...> - 2007-11-21 01:44:06
|
Hi Guys, I have problem with executing the remote command , like mkdir , chmod etc... . If they are executed successfully they doesn't return anything. I need someway to verify that they got executed successfully. Is there any idea? Second problem I have is that I am executing the remote command , first I make the ssh connection then I send the command one by one. Problem is that when will I get to particular command is get finished. because I guess slave system is not returning the EOF as that is closing the stdout may be stdin also. I did something like that... $exp->("commad;echo command finished"); and I expect the "command finished". $exp->expect("600","command finished"); Here I am hardcoding the 600 seconds to wait for that. If any script/command takes more than 600 seconds then obiviously it will fail. I want to wait for forever until I get the "command finished". Please don't tell me to do the $exp->expect(undef) because I am not able to receive the EOF from slave system. I do not want to put any time limitation like 600 seconds. I want it should wait for forever for "command finished" not for EOF. I read all the tutorial what I get is: ou are probably on one of the systems where the master doesn't get an EOF when the slave closes stdin/out/err. One possible solution is when you spawn a process, follow it with a unique string that would indicate the process is finished. $process = Expect->spawn('telnet somehost; echo ____END____'); And then $process->expect($timeout,'____END____','other','patterns'); I did not get this line what the 'other' and 'pattern' mean over here. If anyone is able to solve this problem really that will be better for me. Thanks, Praveen Mall |
From: Roland G. <rgi...@cp...> - 2007-11-15 16:00:45
|
ahem, this seems to be a permission problem on the /dev/pts/, /dev/ptmx etc. why not try to fix that? sp...@nc... wrote: ... > IO::Tty::open_slave(nonfatal): open(/dev/pts/368): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > pty_allocate(nonfatal): open(/dev/ptmx): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > IO::Tty::pty_allocate(nonfatal): grantpt(): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > IO::Tty::pty_allocate(nonfatal): unlockpt(): Inappropriate ioctl for device at /tools/perl/lib/IO/Pty.pm line 24. > aft spwn > > I'm going to try putting the pragma's in the Pty module now. > |
From: <sp...@nc...> - 2007-11-15 15:52:09
|
> Date: Sun, 11 Nov 2007 08:02:33 -0900 > From: Ken Irving <fn...@ua...> > Subject: Re: [Expectperl-discuss] IO:tty errors > To: exp...@li... > Message-ID: <20071111170233.GA16307@localhost> > Content-Type: text/plain; charset=us-ascii > > On Wed, Nov 07, 2007 at 04:29:52PM -0500, sp...@nc... wrote: > > Hey all, > > > > I've inherited some code that i need to fix up. There is a shell script > > that calls a perl program. The shell script is suid to a non-root user. In > > the perl script they did a set real id to effective id. With this setup > > all works, but it's a gapping security hole. the perl script uses expect > > to spawn a telnet session, and you can ctrl-] out of the telnet and > > ! to get a shell script as the suid user. I took out the set real id = > > to effective id and everything seems to work ok, but i get the following > > errors on spawing the telnet: > > > > IO::Tty::open_slave(nonfatal): open(/dev/pts/2): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > > pty_allocate(nonfatal): open(/dev/ptmx): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > > IO::Tty::pty_allocate(nonfatal): grantpt(): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. > > IO::Tty::pty_allocate(nonfatal): unlockpt(): Inappropriate ioctl for device at /tools/perl/lib/IO/Pty.pm line 24. > > > > It makes sense to me, seems to be non-fatal, but my users will freak > > at seeing this output. Is there a quick and easy way to turn off these > > error messages? > > > > Thanks > > -S > > $ perldoc -q warnings > Found in /usr/share/perl/5.8/pod/perlfaq7.pod > How do I temporarily block warnings? > > If you are running Perl 5.6.0 or better, the "use warnings" pragma allows fine > control of what warning are produced. See perllexwarn for more details. > > { > no warnings; # temporarily turn off warnings > $a = $b + $c; # I know these might be undef > } > > If you have an older version of Perl, the $^W variable (documented in perlvar) > controls runtime warnings for a block: > > { > local $^W = 0; # temporarily turn off warnings > $a = $b + $c; # I know these might be undef > } > > Note that like all the punctuation variables, you cannot currently use my() on > $^W, only local(). > > -- > Ken Irving, fn...@ua... > > > Ken, Thanks for the suggestion, but unfortunately, it didn't work. print "b4 spwn\n"; no warnings; my $telnet = Expect->spawn( "/usr/bin/telnet $mPl $mPrt" ); use warnings; print "aft spwn\n"; gives me: b4 spwn IO::Tty::open_slave(nonfatal): open(/dev/pts/368): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. pty_allocate(nonfatal): open(/dev/ptmx): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. IO::Tty::pty_allocate(nonfatal): grantpt(): Permission denied at /tools/perl/lib/IO/Pty.pm line 24. IO::Tty::pty_allocate(nonfatal): unlockpt(): Inappropriate ioctl for device at /tools/perl/lib/IO/Pty.pm line 24. aft spwn I'm going to try putting the pragma's in the Pty module now. |
From: Matt Z. <mzagrabe@d.umn.edu> - 2007-11-15 14:50:19
|
On Wed, 2007-11-14 at 17:58 -0600, Noah wrote: > Matt, >=20 > I am not doing something correct here. No, I am not doing something correct. I mistakenly sent you code snippets that made use of Net::Telnet. Here is a little more complete set of code, note that I may have missed copying something from my source files. Nevertheless, you will get the idea. my $found_prompt =3D undef; my $text_io =3D ''; my $exp =3D &log_in_to_infrastructure($configs, $infrastructure, \$text_io, \$found_prompt, $command); # process text_io here if you want. if ($found_prompt) { $found_prompt =3D undef; $text_io =3D ''; &send_and_receive($configs, "show interfaces status\n", \$text_io, $exp, \$found_prompt); # process text_io here } sub send_and_receive { my $configs =3D shift; my $send_string =3D shift; my $receive_buffer =3D shift; my $expect_object =3D shift; my $wait_for_found =3D shift; my $more_output =3D (@_) ? shift : '--More--'; my $continue_command =3D (@_) ? shift : ' '; my $wait_for =3D (@_) ? shift : '>$'; # set up logging the output to the buffer if ($receive_buffer ne undef) { $expect_object->log_file(sub { $$receive_buffer .=3D shift;}); } =20 # send the string $expect_object->send($send_string); # dont stop logging until we have seen the $wait_for $expect_object->expect($configs->{'management_timeout'}, [ qr/$more_output/i, sub {my $self =3D shift; $self->send($continue_command); exp_continue;}], # 1924 specific prompt [ qr/\[X\] Exit.*:/ism, sub { $$wait_for_found =3D 1; undef;}], # user defined prompt [ qr/$wait_for/i, sub { $$wait_for_found =3D 1; undef;}]); } sub log_in_to_infrastructure { my $configs =3D shift; my $infrastructure =3D shift; my $receive_buffer =3D shift; my $wait_for_found =3D shift; my $command =3D (@_) ? shift : 'telnet'; my $use_menu_1924 =3D (@_) ? shift : undef; my $wait_for =3D (@_) ? shift : '>$'; my $username =3D (@_) ? shift : $configs->{'management_user'}; my $password =3D (@_) ? shift : $configs->{'management_password'}; if ($command eq 'ssh') { $command =3D '/usr/bin/ssh -l '.$username.' '; } else { $command =3D '/usr/bin/telnet '; } my $exp =3D new Expect; $exp->slave->stty(qw(raw -echo)); my $exp =3D Expect->spawn("$command $infrastructure") or die "Cannot spawn $command: $!\n"; $exp->log_stdout(0); if ($receive_buffer ne undef) { $exp->log_file(sub { $$receive_buffer .=3D shift;}); } # note retval is currently unused my $retval =3D $exp->expect($configs->{'management_timeout'}, [ qr/user(name)?: /i, sub { my $self =3D shift; $self->send("$username\n"); exp_continue;}], [ qr/password:\s*/i, sub { my $self =3D shift; $self->send("$password\n"); exp_continue;}], [ qr/Catalyst 1900 Management Console.*Enter Selection: /ism, sub { my $self =3D shift; $self->send($use_menu_1924 ? 'm' : 'k'); exp_continue;}], [ qr/\[X\] Exit Management Console.*Enter Selection:/ism, sub { $$wait_for_found =3D 1; undef;}], # if first time ssh'ing to a infrastructure, then accept # the public key [ qr/\(yes\/no\)\?/i, sub { my $self =3D shift; $self->send("yes\n"); exp_continue;}], [ qr/$wait_for/i, sub { $$wait_for_found =3D 1; undef;}]); return $exp; } > I run my script and get the following: > "Can't call method "put" on an undefined value at ./maintenance.check.pl=20 > line 96." >=20 > Cheers, >=20 > Noah >=20 >=20 > Matt Zagrabelny wrote: > > On Wed, 2007-11-14 at 15:39 -0600, Noah wrote: > >=20 > > [...] > >=20 > >> is there a way to capture the output with perl-expect into an array? > >=20 > > Here are some snippets of what I have done in the past, though I do > > things a little differently now, you will get the idea... hopefully. ;) > >=20 > > Subroutine to send a command to Cisco devices and capture the output in > > the scalar reference $receive_buffer. > >=20 > > sub send_and_receive { > > my $configs =3D shift; > > my $send_string =3D shift; > > my $receive_buffer =3D shift; > > my $command =3D shift; > > my $wait_for_found =3D (@_) ? shift : undef; > > my $more_output =3D (@_) ? shift : '--More--'; > > my $continue_command =3D (@_) ? shift : " ";=20 > > my $wait_for =3D (@_) ? shift : '>$'; > > =20 > > # send whatever it is we are to send > > $command->put($send_string); > >=20 > > # now wait for the "wait_for" meanwhile saving > > # all the output into receive_buffer > > my $done =3D undef; > > until ($done) { > > my ($prematch, $match) =3D (undef, undef); > > ($prematch, $match) =3D > > $command->waitfor(Match =3D> '/'.$more_output.'/i', > > Match =3D> '/'.$wait_for.'/i', > > Match =3D> '/\\[X\\] Exit.*:/ism', > > Timeout =3D> $configs->{management_timeout}); > >=20 > > if ($receive_buffer ne undef) { > > $$receive_buffer .=3D $prematch.$match; > > } =20 > >=20 > > if ($match =3D~ /$more_output/i) { > > $command->put($continue_command); > > } elsif ($match =3D~ /$wait_for/) { > > $$wait_for_found =3D 1 if ($wait_for_found); > > $done =3D 1;=20 > > } elsif ($match =3D~ /\[X\] Exit.*:/ism) { > > $$wait_for_found =3D 1 if ($wait_for_found); > > $done =3D 1;=20 > > } =20 > > } > > } > >=20 > > $text_io =3D ''; > > &send_and_receive($configs, > > "show interface status\n", > > \$text_io, > > $connection, > > \$found_prompt); > >=20 > > my @lines =3D split /\n/, $text_io; > > for (@lines) { > > $_ =3D &trim($_); > > } > >=20 > > sub trim { > > my $s =3D shift; > > $s =3D~ s/^\s*//; > > $s =3D~ s/\s*$//; > > return $s; > > } =20 > >=20 [...] --=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 |