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: anthony <ac...@op...> - 2003-12-02 14:51:56
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Using pix to get configs for multiple types of devices ( pix, nokias, etc ). Many devices are behind jump boxes so I log on to those first and then ssh to the network/target device. For some jump boxes after I send the target password I get no data back. Expect sit at "Waiting for new data" Now if I expect on nothing ( .* ) and send the next command ( en ) I then see the data I would have expected to see in the previous send/expect routine. I've tried different sleep steps, clearing the accumulater etc..... This was only with a few particular FSecure ssh daemons but it just happened with an openssh jump_box that was working fine before. Any suggestions? The code work as expected for other jump_boxes and pix devices. I guess I should try using a working jump_box to the same "problematic" pix to rule out if it's the jump_box or the pix..... - -- acqant What's in your Sendmail queue? http://qparser.sourceforge.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/zKb/eDVHAE9jNDwRAmyCAKC/AuI4jLV/uwKECiSgnA1JxcoJ3gCdHMkP 6rq1HmqvT7Uuf33Gre3ahhA= =8DTn -----END PGP SIGNATURE----- |
From: Benjamin <mai...@sa...> - 2003-11-17 22:26:54
|
Adding te $exp-expect at the end solved the issue. Now I just need to be able to capture the output. Thanks, Ben ---------- Original Message ----------- From: "Andrew & Laurie White" <and...@ve...> To: "Benjamin" <mai...@sa...> Sent: Sat, 15 Nov 2003 18:56:04 -0500 Subject: Re: [Expectperl-discuss] Perl Expect and sh > i don't have my unix machine nearby but a quick thought was to use \r > instead of \n to the ls command > > you may also want to have another $exp->expect(10, "sh"); > after the ls send . > > ----- Original Message ----- > From: "Benjamin" <mai...@sa...> > To: <exp...@li...> > Sent: Friday, November 14, 2003 6:51 PM > Subject: [Expectperl-discuss] Perl Expect and sh > > > Hi all, > > I'm trying to play with Perl-Expect and I'm not having much success > getting it > > to do a simple task. Here is the code: > > > > use Expect; > > > > $Expect::Exp_Internal = 1; > > > > my $exp = Expect->spawn("/bin/sh") > > or die "Cannot spawn /bin/bash: $!\n"; > > #print "got here\n"; > > $exp->expect(10, "sh"); > > $exp->send("ls \n"); > > > > With it, I'm trying to spawn sh and then do an ls (I know I can do ls > > directly, but I'm trying it this way for this example), but when I do > this, > > I get the following output: > > > > Spawned '/bin/sh' > > spawn id(3) > > Pid: 5442 > > Tty: /dev/pts/2 > > Expect::spawn('Expect','/bin/sh') called at test.pl line 5 > > Starting EXPECT pattern matching... > > Expect::expect('Expect=GLOB(0x806479c)',10,'sh') called at test.pl > > line 8 > > spawn id(3): list of patterns: > > #1: -ex `sh' > > > > > > spawn id(3): Does `' > > match: > > pattern #1: -ex `sh'? No. > > > > Waiting for new data (10 seconds)... > > sh-2.05b$ > > spawn id(3): Does `sh-2.05b$ ' > > match: > > pattern #1: -ex `sh'? YES!! > > Before match string: `' > > Match string: `sh' > > After match string: `-2.05b$ ' > > Matchlist: () > > Returning from expect successfully. > > Sending 'ls \n' to spawn id(3) > > Expect::print('Expect=GLOB(0x806479c)','ls \x{a}') called at > test.pl > > line 9 > > [userid@machineid userid]$ > > > > Without getting a list of the files. Any help is appreciated. I am using > > RedHat 9.0 with the latest expect modules from CPAN.org. > > > > Thanks, > > Ben > > > > > > ------------------------------------------------------- > > This SF. Net email is sponsored by: GoToMyPC > > GoToMyPC is the fast, easy and secure way to access your computer from > > any Web browser or wireless device. Click here to Try it Free! > > https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl > > _______________________________________________ > > Expectperl-discuss mailing list > > Exp...@li... > > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss ------- End of Original Message ------- |
From: Schuller, B. <Bil...@in...> - 2003-11-17 21:49:43
|
It's Monday. I didn't read the question before replying. Sorry. Use a "/r" instead of a "/n" unless you're running in RAW mode: $obj_name->raw_pty(1); # Use /n when in RAW, /r otherwise. -----Original Message----- From: exp...@li... [mailto:exp...@li...] On Behalf Of Schuller, Bill Sent: Monday, November 17, 2003 1:38 PM To: 'Benjamin'; exp...@li... Subject: RE: [Expectperl-discuss] Perl Expect and sh I use this regex to match for shell prompts: $shell_prompt= '(.*%|.*#|.*>|.*\\$) $'; and call expect like so: $obj_name->expect($timeout, '-re', $shell_prompt); It works with most prompts (I've tested on bash, sh, ksh and tcsh on Solaris, Windows (Cygwin) and Tru64 boxes with many users' funky prompts) that I have come across and doesn't interfere with any other data I've run into either. Bill Schuller Bil...@in... bi...@wu... -----Original Message----- From: Benjamin [mailto:mai...@sa...] Sent: Friday, November 14, 2003 3:51 PM To: exp...@li... Subject: [Expectperl-discuss] Perl Expect and sh Hi all, I'm trying to play with Perl-Expect and I'm not having much success getting it to do a simple task. Here is the code: use Expect; $Expect::Exp_Internal = 1; my $exp = Expect->spawn("/bin/sh") or die "Cannot spawn /bin/bash: $!\n"; #print "got here\n"; $exp->expect(10, "sh"); $exp->send("ls \n"); With it, I'm trying to spawn sh and then do an ls (I know I can do ls directly, but I'm trying it this way for this example), but when I do this, I get the following output: Spawned '/bin/sh' spawn id(3) Pid: 5442 Tty: /dev/pts/2 Expect::spawn('Expect','/bin/sh') called at test.pl line 5 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x806479c)',10,'sh') called at test.pl line 8 spawn id(3): list of patterns: #1: -ex `sh' spawn id(3): Does `' match: pattern #1: -ex `sh'? No. Waiting for new data (10 seconds)... sh-2.05b$ spawn id(3): Does `sh-2.05b$ ' match: pattern #1: -ex `sh'? YES!! Before match string: `' Match string: `sh' After match string: `-2.05b$ ' Matchlist: () Returning from expect successfully. Sending 'ls \n' to spawn id(3) Expect::print('Expect=GLOB(0x806479c)','ls \x{a}') called at test.pl line 9 [userid@machineid userid]$ Without getting a list of the files. Any help is appreciated. I am using RedHat 9.0 with the latest expect modules from CPAN.org. Thanks, Ben ------------------------------------------------------- This SF. Net email is sponsored by: GoToMyPC GoToMyPC is the fast, easy and secure way to access your computer from any Web browser or wireless device. Click here to Try it Free! https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss ------------------------------------------------------- This SF. Net email is sponsored by: GoToMyPC GoToMyPC is the fast, easy and secure way to access your computer from any Web browser or wireless device. Click here to Try it Free! https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Schuller, B. <Bil...@in...> - 2003-11-17 21:38:24
|
I use this regex to match for shell prompts: $shell_prompt= '(.*%|.*#|.*>|.*\\$) $'; and call expect like so: $obj_name->expect($timeout, '-re', $shell_prompt); It works with most prompts (I've tested on bash, sh, ksh and tcsh on Solaris, Windows (Cygwin) and Tru64 boxes with many users' funky prompts) that I have come across and doesn't interfere with any other data I've run into either. Bill Schuller Bil...@in... bi...@wu... -----Original Message----- From: Benjamin [mailto:mai...@sa...] Sent: Friday, November 14, 2003 3:51 PM To: exp...@li... Subject: [Expectperl-discuss] Perl Expect and sh Hi all, I'm trying to play with Perl-Expect and I'm not having much success getting it to do a simple task. Here is the code: use Expect; $Expect::Exp_Internal = 1; my $exp = Expect->spawn("/bin/sh") or die "Cannot spawn /bin/bash: $!\n"; #print "got here\n"; $exp->expect(10, "sh"); $exp->send("ls \n"); With it, I'm trying to spawn sh and then do an ls (I know I can do ls directly, but I'm trying it this way for this example), but when I do this, I get the following output: Spawned '/bin/sh' spawn id(3) Pid: 5442 Tty: /dev/pts/2 Expect::spawn('Expect','/bin/sh') called at test.pl line 5 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x806479c)',10,'sh') called at test.pl line 8 spawn id(3): list of patterns: #1: -ex `sh' spawn id(3): Does `' match: pattern #1: -ex `sh'? No. Waiting for new data (10 seconds)... sh-2.05b$ spawn id(3): Does `sh-2.05b$ ' match: pattern #1: -ex `sh'? YES!! Before match string: `' Match string: `sh' After match string: `-2.05b$ ' Matchlist: () Returning from expect successfully. Sending 'ls \n' to spawn id(3) Expect::print('Expect=GLOB(0x806479c)','ls \x{a}') called at test.pl line 9 [userid@machineid userid]$ Without getting a list of the files. Any help is appreciated. I am using RedHat 9.0 with the latest expect modules from CPAN.org. Thanks, Ben ------------------------------------------------------- This SF. Net email is sponsored by: GoToMyPC GoToMyPC is the fast, easy and secure way to access your computer from any Web browser or wireless device. Click here to Try it Free! https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Benjamin <mai...@sa...> - 2003-11-14 23:51:21
|
Hi all, I'm trying to play with Perl-Expect and I'm not having much success getting it to do a simple task. Here is the code: use Expect; $Expect::Exp_Internal = 1; my $exp = Expect->spawn("/bin/sh") or die "Cannot spawn /bin/bash: $!\n"; #print "got here\n"; $exp->expect(10, "sh"); $exp->send("ls \n"); With it, I'm trying to spawn sh and then do an ls (I know I can do ls directly, but I'm trying it this way for this example), but when I do this, I get the following output: Spawned '/bin/sh' spawn id(3) Pid: 5442 Tty: /dev/pts/2 Expect::spawn('Expect','/bin/sh') called at test.pl line 5 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x806479c)',10,'sh') called at test.pl line 8 spawn id(3): list of patterns: #1: -ex `sh' spawn id(3): Does `' match: pattern #1: -ex `sh'? No. Waiting for new data (10 seconds)... sh-2.05b$ spawn id(3): Does `sh-2.05b$ ' match: pattern #1: -ex `sh'? YES!! Before match string: `' Match string: `sh' After match string: `-2.05b$ ' Matchlist: () Returning from expect successfully. Sending 'ls \n' to spawn id(3) Expect::print('Expect=GLOB(0x806479c)','ls \x{a}') called at test.pl line 9 [userid@machineid userid]$ Without getting a list of the files. Any help is appreciated. I am using RedHat 9.0 with the latest expect modules from CPAN.org. Thanks, Ben |
From: Schuller, B. <Bil...@in...> - 2003-10-28 16:56:07
|
Here's a quick example of how I do it. It takes a similar approach to what you have done. It's a bit of a kluge, but it gets the job done. I welcome constructive criticism. Bill Schuller Systems Engineer, Intuit, Inc. bil...@in... ... # If su() returns anything but 0, you haven't su'd and therefore can't do # your work as root, so skip this host and go to the next one. next if su(/$exp_obj, root, password); ... sub su { local(*obj_name, $user, $password)=@_; my($timeout)=45; $obj_name->send("\n"); $obj_name->expect($timeout, '-re', $shell_prompt); $obj_name->send("/bin/su $user\n"); %su_status=(); $su_loopbreaker=0; # allows us to react to multiple 'events' with one expect command until ($su_loopbreaker==1){ $obj_name->expect($timeout, [ qr/password: /i, sub { my $self = shift; $self->send("$password\n"); $su_status{password}=($self->before()); exp_continue; }], [ qr/sorry/i, sub { my $self = shift; $su_status{ssherror}=($self->before()); $su_loopbreaker=1; }], [ qr/denied/i, sub { my $self = shift; $su_status{denied}=($self->before()); $su_loopbreaker=1; }], ['-re', $shell_prompt, sub { my $self = shift; $su_status{success}=($self->before()); $su_loopbreaker=1; }], [timeout, sub { my $self = shift; $su_status{timeout}="Timed out after $timeout sec"; $su_loopbreaker=1; }] ); } # Now check to see if we REALLY made it to root (needs some work) $_=run_cmd(\$obj_name, '/bin/id'); /\((.*?)\)/; my($whoami)=$1; if ($su_status{sorry}){ return "$su_status{sorry}"; }elsif ($su_status{timeout}){ return "$su_status{timeout}"; }elsif ($su_status{denied}){ return "$su_status{denied}"; }elsif ($su_status{success}){ if ($whoami eq $user){ return 0; }else{ return "Couldn't su to $user, still $whoami"; } }else{ @su_keys=(keys %su_status); return "Whoa! We're $whoami, is that right?"; } } -----Original Message----- From: Brett Meehan [mailto:bre...@qa...] Sent: Monday, October 27, 2003 5:05 PM To: exp...@li... Subject: [Expectperl-discuss] ssh script to propegate commands to multiple servers Folks, I am new to expectperl and am having some conceptual troubles (I think). I am using ssh to issue a command to multiple hosts read from a text file. I have kludged together some expect code to handle some responses I may get to the ssh command. I would like to make my code a little neater and be able to trap the condition where the host does not respond at all to the command (ie it is powered off at the time). Therefore I have the following questions (to be followed by a section of my code to illustrate my problem). I really hate the whole $skiphost thing and would really like to be able to just issue a next; for the conditions which require no further interaction with that particular host (thus returning to the top of my while loop). This however does not seem to work. If I do this, the expect call is not broken and continues until timeout and then some other code in the whileloop is eroniously executed. Is there a means of doing this (ie something like exp_next; instead of exp_continue)? How can i differentiate a situation where the host just does not respond? I thought to do this by catching when the expect call timesout but with the current logic it timesout in every condition (hopefully a solution to pont 1 above will also resolve this issue). Kind Regards Brett while (<HOSTS>) { chomp(); @nexthost = split(/,/, $_); # take first field of each line as a valid host (comma seperated data) # Issue the command to the current host $ssh = Expect->spawn("ssh $nexthost[0] $mycommand") or die "Couldn't start program: $!\n"; #$ssh->debug(1); $ssh->log_file("exp.log"); # prevent the program's output from being shown on our STDOUT $ssh->log_stdout(0); $ssh->expect(20, [ qr/continue/i, sub { my $self = shift; $self->send("yes\n"); exp_continue; }], [ qr/denied/i, sub { print "your password for $nexthost[0] was incorrect - please reenter: "; ReadMode 'noecho'; $newpass = <STDIN>; # read the next line chomp($newpass); ReadMode 'normal'; if ($newpass) {$password = $newpass;} $newpass=""; print "\n"; exp_continue; }], [ qr/password:/i, sub { my $self = shift; $self->send("$password\n"); exp_continue; }], [ qr/publickey/i, sub { print "your login to $nexthost[0] failed - maybe you dont have an account there "; $skiphost = "yes"; exp_continue; }], [ qr/not known/i, sub { print "host $nexthost[0] is unknown\n"; $skiphost = "yes"; exp_continue; }], [ qr/closed/i, sub { print "host $nexthost[0] closed the connection - your password may have expired here\n"; $skiphost = "yes"; exp_continue; }], [ qr/connection/i, sub { print "host $nexthost[0] closed the connection\n"; $skiphost = "yes"; exp_continue; }], [ qr/refused/i, sub { print "host $nexthost[0] is not responding on port 22\n"; $skiphost = "yes"; exp_continue; }], ); if ($skiphost) { $skiphost = ""; next; print "you shouldnt see this as it should have skipped"; } # close the expect for ssh $ssh->soft_close(); <some other stuff> <more other stuff> } # loop to next host close HOSTS; *******************Confidentiality and Privilege Notice******************* This email is intended only to be read or used by the addressee. It is confidential and may contain legally privileged information. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone, and you should destroy this message and kindly notify the sender by reply email. Confidentiality and legal privilege are not waived or lost by reason of mistaken delivery to you. Qantas Airways Limited ABN 16 009 661 901 Visit Qantas online at http://www.qantas.com.au ------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/ _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Brett M. <bre...@qa...> - 2003-10-28 01:05:28
|
Folks, I am new to expectperl and am having some conceptual troubles (I think). I am using ssh to issue a command to multiple hosts read from a text file. I have kludged together some expect code to handle some responses I may get to the ssh command. I would like to make my code a little neater and be able to trap the condition where the host does not respond at all to the command (ie it is powered off at the time). Therefore I have the following questions (to be followed by a section of my code to illustrate my problem). I really hate the whole $skiphost thing and would really like to be able to just issue a next; for the conditions which require no further interaction with that particular host (thus returning to the top of my while loop). This however does not seem to work. If I do this, the expect call is not broken and continues until timeout and then some other code in the whileloop is eroniously executed. Is there a means of doing this (ie something like exp_next; instead of exp_continue)? How can i differentiate a situation where the host just does not respond? I thought to do this by catching when the expect call timesout but with the current logic it timesout in every condition (hopefully a solution to pont 1 above will also resolve this issue). Kind Regards Brett while (<HOSTS>) { chomp(); @nexthost = split(/,/, $_); # take first field of each line as a valid host (comma seperated data) # Issue the command to the current host $ssh = Expect->spawn("ssh $nexthost[0] $mycommand") or die "Couldn't start program: $!\n"; #$ssh->debug(1); $ssh->log_file("exp.log"); # prevent the program's output from being shown on our STDOUT $ssh->log_stdout(0); $ssh->expect(20, [ qr/continue/i, sub { my $self = shift; $self->send("yes\n"); exp_continue; }], [ qr/denied/i, sub { print "your password for $nexthost[0] was incorrect - please reenter: "; ReadMode 'noecho'; $newpass = <STDIN>; # read the next line chomp($newpass); ReadMode 'normal'; if ($newpass) {$password = $newpass;} $newpass=""; print "\n"; exp_continue; }], [ qr/password:/i, sub { my $self = shift; $self->send("$password\n"); exp_continue; }], [ qr/publickey/i, sub { print "your login to $nexthost[0] failed - maybe you dont have an account there "; $skiphost = "yes"; exp_continue; }], [ qr/not known/i, sub { print "host $nexthost[0] is unknown\n"; $skiphost = "yes"; exp_continue; }], [ qr/closed/i, sub { print "host $nexthost[0] closed the connection - your password may have expired here\n"; $skiphost = "yes"; exp_continue; }], [ qr/connection/i, sub { print "host $nexthost[0] closed the connection\n"; $skiphost = "yes"; exp_continue; }], [ qr/refused/i, sub { print "host $nexthost[0] is not responding on port 22\n"; $skiphost = "yes"; exp_continue; }], ); if ($skiphost) { $skiphost = ""; next; print "you shouldnt see this as it should have skipped"; } # close the expect for ssh $ssh->soft_close(); <some other stuff> <more other stuff> } # loop to next host close HOSTS; *******************Confidentiality and Privilege Notice******************* This email is intended only to be read or used by the addressee. It is confidential and may contain legally privileged information. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone, and you should destroy this message and kindly notify the sender by reply email. Confidentiality and legal privilege are not waived or lost by reason of mistaken delivery to you. Qantas Airways Limited ABN 16 009 661 901 Visit Qantas online at http://www.qantas.com.au |
From: Mark N. <ma...@li...> - 2003-10-27 16:50:17
|
Hi, This is my first post ever to a mailing list, so I apologise in advance for any bad netiquette! I have a script that connects to a firewall when run via setuid root. I'm trying to write a second script which calls this first one for several different firewalls, runs a couple of commands on them, then quits. The first script returns control back to the user via a call to $firewall->interact($stdin). My question is - is there any way to get control back, following a system call to the first script? I have this, and it works as expected, but I can't continue... #Connect to each firewall in turn and execute commands foreach $firewall (@firewalls) { system ("s0", "fwconnect", $firewall); #do command here! } running it leaves me in control at the firewall's prompt for each firewall - typing 'exit' moves onto the next one in the list. Thanks in advance, Mark |
From: Reidy, R. <Ron...@ar...> - 2003-10-25 23:00:54
|
Roland, Thanks for the Perl offer - but I already tried it in Perl and could not = get anything to work (I don't even remeber the problems now), so I = switched right to Expect. Anyway, when I composed this message, I failed to mention my = environment: SuSE Linux: 7.2 Expect 5.? (latest version from the official site) tcl/tk 8.4.4 I had already Googled for the error, but I found nothing I understood to = be pertinent, hence the post. Thanks again for your time. ----------------- Ron Reidy Senior DBA Array BioPharma, Inc. -----Original Message----- From: Roland Giersig [mailto:RGi...@cp...] Sent: Friday, October 24, 2003 12:15 AM To: Reidy, Ron Cc: exp...@li... Subject: Re: [Expectperl-discuss] "Tcl_RegisterChannel: duplicate channel names" error Reidy, Ron wrote: > > Hi, >=20 > I am new to Tcl and Expect.=20 So, welcome to the wonderful world of Perl!! > I have a script which I use to synchronize an Oracle database. Last = night the script failed and I received the following error from the = script: >=20 > spawn sqlplus /nolog > Tcl_RegisterChannel: duplicate channel names > open(slave pty): open(/dev/pts/2,rw) =3D -1 (no such file or = directory) This looks like a problem with Tcl or with your ptys. Googling for the=20 error message shows that someone has patched that line out of Tcl, but I = cannot tell, if that patch is correct. So you better go ask somebody=20 from the Tcl world about that... Or you switch to Perl and try again, in which case I'd be glad to=20 provide help with any technical errors... ;o) Cheers! Roland This electronic message transmission is a PRIVATE communication which = contains information which may be confidential or privileged. The information is = intended=20 to be for the use of the individual or entity named above. If you are = not the=20 intended recipient, please be aware that any disclosure, copying, = distribution=20 or use of the contents of this information is prohibited. Please notify = the sender of the delivery error by replying to this message, or notify us = by telephone (877-633-2436, ext. 0), and then delete it from your system. |
From: <db...@CT...> - 2003-10-24 19:21:48
|
You'll probably have better luck with this one at "comp.lang.tcl" newsgroup. That's the official place for Tcl/Expect. Barring whatelse you get here (and there), To trap errors and return failed status to shell (I put in log file since I assumed you'd want to see errors in a file somewhere in the morning) , you can trap expected culprit signals with something like this in your script: trap { set f [open "/tmp/error_log.txt" "w"] puts $f "got signal named [trap -name]" puts $f "got signal numbered [trap -number]" puts $f "at [date]" close $f exit } {SIGINT SIGKILL SIGPIPE SIGTERM SIGCHILD} something like this anyways.. (no logic to the signals I put in example) just list all the signals you want to trap on in the second argument list. If you want your script to still exit when it 'traps' one of these signals, you must "exit", else, use "return" to go back to where it left off like a procedure call or something. if you want to associate different signals with different actions, just make different trap declarations which will "trap" different signals and do something different. Regarding the error itself, make sure you're running Tcl greater than 8.1. From what I could find, there was a problem like this that was fixed in 8.1. hope this helps "Reidy, Ron" <Ron...@ar...> To: Sent by: <exp...@li...> exp...@li...urc cc: eforge.net Subject: [Expectperl-discuss] "Tcl_RegisterChannel: duplicate channel names" error 10/23/2003 11:19 AM Hi, I am new to Tcl and Expect. I have a script which I use to synchronize an Oracle database. Last night the script failed and I received the following error from the script: spawn sqlplus /nolog Tcl_RegisterChannel: duplicate channel names open(slave pty): open(/dev/pts/2,rw) = -1 (no such file or directory) Can anyone point me to some kind of information which describes this, how to trap this error and return a failed status to the shell, etc.? My expect script is this: proc startup_nomount {} { global expect_out global argv0 set max_try 3 for {set i 0} {$i<$max_try} {incr i} { send "startup nomount\r" expect { -re "ORA-\[0-9]*" { send_error "\nEXPECT_WARN-001: Oracle error during 'startup nomount' ... retrying\n" } "SQL> " { break } } } if ($i>=$max_try) { send_error "\nEXPECT_ERR-001: Cannot start Oracle ... max tries ($max) exceeded.\n" send_user $expect_out(buffer) exit 1 } } spawn sqlplus /nolog expect "SQL> " send "connect / as sysdba\r" expect "SQL> " send "shutdown immediate\r" expect "SQL> " # # attempt to start Oracle # startup_nomount send "alter database mount standby database;\r" expect { "ERROR*" { send_error "\nEXPECT_ERR-002: Cannot mount database\n"; exit 2 } "SQL> " } remove_nulls 0 send "recover standby database;\r" expect null remove_nulls 1 set timeout -1 send "auto\r" expect "SQL> " expect { "SP2*" { send_error "\nEXPECT_WARN-002: Failure issuing 'auto' command ... transactions not recovered\n" } "SQL> " } send "alter database open read only;\r" expect { -re "ORA-\[0-9]*" { send_error "\nEXPECT_ERR-005: Cannot open database 'read only' ... database is not available\n" exit 5 } "SQL> " } send "quit\r" send_user "\n\nOracle manual recovery complete\n" close Thank you in advance for any insight or help you can give me. ----------------- Ron Reidy Senior DBA Array BioPharma, Inc. This electronic message transmission is a PRIVATE communication which contains information which may be confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. Please notify the sender of the delivery error by replying to this message, or notify us by telephone (877-633-2436, ext. 0), and then delete it from your system. ------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/ _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Roland G. <RGi...@cp...> - 2003-10-24 06:19:25
|
Reidy, Ron wrote: > > Hi, > > I am new to Tcl and Expect. So, welcome to the wonderful world of Perl!! > I have a script which I use to synchronize an Oracle database. Last night the script failed and I received the following error from the script: > > spawn sqlplus /nolog > Tcl_RegisterChannel: duplicate channel names > open(slave pty): open(/dev/pts/2,rw) = -1 (no such file or directory) This looks like a problem with Tcl or with your ptys. Googling for the error message shows that someone has patched that line out of Tcl, but I cannot tell, if that patch is correct. So you better go ask somebody from the Tcl world about that... Or you switch to Perl and try again, in which case I'd be glad to provide help with any technical errors... ;o) Cheers! Roland |
From: Reidy, R. <Ron...@ar...> - 2003-10-24 04:38:45
|
Hi, I am new to Tcl and Expect. I have a script which I use to synchronize = an Oracle database. Last night the script failed and I received the = following error from the script: spawn sqlplus /nolog Tcl_RegisterChannel: duplicate channel names open(slave pty): open(/dev/pts/2,rw) =3D -1 (no such file or directory) Can anyone point me to some kind of information which describes this, = how to trap this error and return a failed status to the shell, etc.? My expect script is this: proc startup_nomount {} { global expect_out global argv0 set max_try 3 for {set i 0} {$i<$max_try} {incr i} { send "startup nomount\r" expect { -re "ORA-\[0-9]*" { send_error "\nEXPECT_WARN-001: Oracle error during 'startup = nomount' ... retrying\n" } "SQL> " { break } } } if ($i>=3D$max_try) { send_error "\nEXPECT_ERR-001: Cannot start Oracle ... max tries = ($max) exceeded.\n" send_user $expect_out(buffer) exit 1 } } spawn sqlplus /nolog expect "SQL> " send "connect / as sysdba\r" expect "SQL> " send "shutdown immediate\r" expect "SQL> " # # attempt to start Oracle # startup_nomount send "alter database mount standby database;\r" expect { "ERROR*" { send_error "\nEXPECT_ERR-002: Cannot mount database\n"; exit 2 } "SQL> " } remove_nulls 0 send "recover standby database;\r" expect null remove_nulls 1 set timeout -1 send "auto\r" expect "SQL> " expect { "SP2*" { send_error "\nEXPECT_WARN-002: Failure issuing 'auto' command ... = transactions not recovered\n" } "SQL> " } send "alter database open read only;\r" expect { -re "ORA-\[0-9]*" { send_error "\nEXPECT_ERR-005: Cannot open database 'read only' ... = database is not available\n" exit 5 } "SQL> " } send "quit\r" send_user "\n\nOracle manual recovery complete\n" close Thank you in advance for any insight or help you can give me. ----------------- Ron Reidy Senior DBA Array BioPharma, Inc. This electronic message transmission is a PRIVATE communication which = contains information which may be confidential or privileged. The information is = intended=20 to be for the use of the individual or entity named above. If you are = not the=20 intended recipient, please be aware that any disclosure, copying, = distribution=20 or use of the contents of this information is prohibited. Please notify = the sender of the delivery error by replying to this message, or notify us = by telephone (877-633-2436, ext. 0), and then delete it from your system. |
From: David J. <Dav...@Su...> - 2003-10-17 16:33:57
|
Ok I have written a perl script to interact with the user and ask for an ip address. Based on that ip my script calls a subroutine written in expect.pm to login to a server. Grand no problems. What I want to do now is hide the fact that expect is logged onto the server. I would like to return to a menu printed out using the perl "print" command. Then depending on what menu option the user selects another command could be sent-> to the server such as ls or cd Below is the telnet script I use.. sub telSession { my $session = Expect->spawn("telnet $localIP") || die "cannont spawn telnet\n"; $session->expect("username:"); $session->send("$myUname"); $session->expect("passsword:"); $session->send("$myPword"); $session->expect("prompt "); $session->interact; } |
From: Reidy, R. <Ron...@ar...> - 2003-10-15 18:59:07
|
All, I am having a problem using Expect.pm to automate a database refresh = script. My environment: SuSE 7.1 Perl 5.8.0 Expect 1.15 When executing the following command: my $sql =3D Expect->spawn("/path_to_directory/sqlplus /nolog\r"); this error 'Cannot sync with child: Interrupted system call at Expect.pm = line 125' is thrown. I have looked at the Expect.pm source, but I do not understand what the = problem would be with this command. I used the debugger to step through = the code, and all environment variables necessary to run sqlplus are = set, and the path information in the command is correct also. Can anyone lend me a hand on resolving this issue? Thank you. ----------------- Ron Reidy Senior DBA Array BioPharma, Inc. This electronic message transmission is a PRIVATE communication which = contains information which may be confidential or privileged. The information is = intended=20 to be for the use of the individual or entity named above. If you are = not the=20 intended recipient, please be aware that any disclosure, copying, = distribution=20 or use of the contents of this information is prohibited. Please notify = the sender of the delivery error by replying to this message, or notify us = by telephone (877-633-2436, ext. 0), and then delete it from your system. |
From: Andrew C. <an...@xt...> - 2003-10-10 04:09:12
|
I hope this comes out O.K. My crappy mailler won't let me set the word wrap. On Wed, 2003-10-08 at 17:30, Austin Schutz wrote: > Yeah, that's what you do. You don't need to do interact to accomplish > this. Also, you can use the '-i' flag to expect() to wait for input from both > the device and the user. > Well, that's how I would do it anyway. > > > Austin Following that advice and shamelessly stealing from various examples, I've basically got that working. The guts are: ## Router interface etc configured. ## Logon to the device. $net_telnet->print("telnet $ipaddress /vrf $VRF"); ## Create a handle to STDIN my $stdin = Expect->exp_init( \*STDIN ); $stdin->stty(qw(raw -echo)); $stdin->log_stdout(0); ## Create a handle for the telnet session my $device = Expect->exp_init( \*$net_telnet ); $device->log_stdout(1); $device->log_file($expect_log); $stdin->set_group($device); ## If we see the router prompt we're not on the ## remote device anymore. Exit the expect loop. expect( undef, '-i', [$device], [qr'ROUTER#$'], '-i', [$stdin], [ qr'\n', sub { exp_continue; } ], ); ## Reset teminal or carriage returns get screwed up. $stdin->stty(qw(sane)); print "\nCleaning up config.\n"; bless $net_telnet, 'Net::Telnet'; ##Remove interface and exit. This all seems to be working great. The main problem I had was being able to see what I was typing without the input line being echoed after I pressed enter. After trying a huge combination of terminal settings I read about $exp->set_group and that fixed everything. The beauty of this setup is by adding more regexs you could parse/filter the input. For anyone who's wondering, I always use a Net::Telnet object instead of a raw IO socket on TCP 23 because I got caught out a while back by hosts expecting telnet options you can't do with raw IO. Having struggled through this I'm "interested" now, so I'd appreciate any comments or suggestions on how to do this better. Thanks for everyones help. Cheers, Andrew Anyone who isn't confused really doesn't understand the situation. -Edward R. Murrow. 1908-1965. |
From: <db...@CT...> - 2003-10-08 20:22:07
|
> My problem is the moron users who won't read the initial text that tells > them to hit control X to exit (interact escape sequence). Most of them > are logging out cleanly from the device and if this was a separate > expect object, control would return to the program and I could clean up > the router. then I'd probably see about spawning a second telnet to the new device alongside the first, instead of invoking telnet from the router to the device in a daisy-chain fashion. This way, you can "interconnect" to the second device, and return control back to the calling program upon either EOF (i.e., user types "exit") or the Ctrl-X sequence; assuming this is how interact works in the Expect.pm module; I've never used it. If this works and you want to do it this way, you may want to terminate the session to the router first before interacting, and then re-establish it after you're done, or keep session open to router, but set the timeout really high. If you absolutely-positively must use interconnect, and must use a daisy-chained session like this, there is an example or two under the paragraph called "preventing bad commands" on pg. 346 of Don Libe's Expect book, which would possibly do what you want using the Tcl flavor. The example I'm looking at on this page would allow a sequence of characters, like "exit" to be intercepted (and possibly manipulated) before sending them on to the interconnected process. hope this helps Andrew Cutler <an...@xt...> Sent by: To: Expectperl-discuss exp...@li...urc <exp...@li...> eforge.net cc: Subject: Re: [Expectperl-discuss] Nested telnet sessions using Expect.pm module 10/08/2003 01:17 PM Hi, What about if you want the last object to be a separate expect instance? I have a situation where I need to: telnet to a cisco router and configure an interface to provide connectivity to another device. telnet from the router to the device and login. interact. logout from the device and fallback to the cisco, deconfigure the interface and shut it down. logoff. My problem is the moron users who won't read the initial text that tells them to hit control X to exit (interact escape sequence). Most of them are logging out cleanly from the device and if this was a separate expect object, control would return to the program and I could clean up the router. The man page says the escape sequence will not work with multiple characters so I can't use "exit" etc. Can I expect from an instance while it's in interact mode? I could look for the logout command or watch for when the prompt changes back to the original router. Any ideas would be hugely appreciated. Cheers, Andrew On Sat, 2003-10-04 at 08:54, Hailey Nguyen wrote: > Hi D. Basham, > > It's definitely very helpful. Chris Muth has sent me an example and I got > my stuff to work with that. But your info is also a great help to me. > > Thanks, > HAiley Theory is what you use to describe an experience. It will never be a substitute. -- Me. Everyday. ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Austin S. <te...@of...> - 2003-10-08 04:32:29
|
On Wed, Oct 08, 2003 at 05:17:47PM +1300, Andrew Cutler wrote: > Hi, > > What about if you want the last object to be a separate expect instance? > I have a situation where I need to: > You could if you wanted turn/copy it into a new object, but that probably won't give you the functionality you're looking for. > telnet to a cisco router and configure an interface to provide > connectivity to another device. > > telnet from the router to the device and login. > interact. > logout from the device and fallback to the cisco, > > deconfigure the interface and shut it down. > logoff. > > My problem is the moron users who won't read the initial text that tells > them to hit control X to exit (interact escape sequence). Most of them > are logging out cleanly from the device and if this was a separate > expect object, control would return to the program and I could clean up > the router. So don't call interact. read from the user and write to the router, and vice versa. > > The man page says the escape sequence will not work with multiple > characters so I can't use "exit" etc. This is true, see above comment. Also you can still look for strings like 'connection closed by foreign host', etc. > > Can I expect from an instance while it's in interact mode? I could look > for the logout command or watch for when the prompt changes back to the > original router. > Yeah, that's what you do. You don't need to do interact to accomplish this. Also, you can use the '-i' flag to expect() to wait for input from both the device and the user. Well, that's how I would do it anyway. Austin |
From: Andrew C. <an...@xt...> - 2003-10-08 04:18:23
|
Hi, What about if you want the last object to be a separate expect instance? I have a situation where I need to: telnet to a cisco router and configure an interface to provide connectivity to another device. telnet from the router to the device and login. interact. logout from the device and fallback to the cisco, deconfigure the interface and shut it down. logoff. My problem is the moron users who won't read the initial text that tells them to hit control X to exit (interact escape sequence). Most of them are logging out cleanly from the device and if this was a separate expect object, control would return to the program and I could clean up the router. The man page says the escape sequence will not work with multiple characters so I can't use "exit" etc. Can I expect from an instance while it's in interact mode? I could look for the logout command or watch for when the prompt changes back to the original router. Any ideas would be hugely appreciated. Cheers, Andrew On Sat, 2003-10-04 at 08:54, Hailey Nguyen wrote: > Hi D. Basham, > > It's definitely very helpful. Chris Muth has sent me an example and I got > my stuff to work with that. But your info is also a great help to me. > > Thanks, > HAiley Theory is what you use to describe an experience. It will never be a substitute. -- Me. Everyday. |
From: Hailey N. <Hai...@Su...> - 2003-10-03 20:56:33
|
Hi D. Basham, It's definitely very helpful. Chris Muth has sent me an example and I got my stuff to work with that. But your info is also a great help to me. Thanks, HAiley > > >>>> Note: A know B but doesn't know C - in another words, to get to C you > have >>>> to go through B. > > Yes.. well, I guess it depends on what you're trying to say behind the > words. Remember that you're spawning ONE process (or should be). Once > you've done that and successfully logged into A, you should INVOKE telnet > client on A to get to B, so there's no more "spawning" (from a perl module > perspective), as B and C have no clue what the heck SPAWN is.. they just > know what telnet is. Just imagine that you are invoking telnet on the > command line from host to host to host, and that's ultimately what expects > doing with the single telnet session you spawned to A. Imagine it that > way and you should be able to see enough of what's going on to know how > to use expect and code it. Remember that each time you hop, the STDOUT > and STDERR channels get lashed together, and become STDIN to the thing > that created it (parent.) They all get lashed together like the Alaskan > pipeline, all the way back to your original spawned process in your > expect script. In this daisy-chain telnet example you're trying to do, > it is the only STDIN that your script should be dealing with. > > I don't know if that's the understanding you need, or if I'm confusing you > more. Bottom line, If you can do it from the command line, i.e., telnet > from A to B to C and so forth, then so can expect. If you can't do it, > then neither can expect. It's that simple. All expect does is provide a > way to automate the steps. The only difference between opening a process > in Perl vs. Expect is that perl (by itself) cannot open a bi-directional > pipe to a process. I.e., it can do this > > open (TELNET, " telnet $HOSTA | "); > > which would allow you to read from the session, or you can do this: > > open (TELNET, "| telnet $HOSTA "); > > to write to the process, but you cannot do both at the same time like > this: > > open (TELNET, "| telnet $HOSTB | "); > > that's where Expect can help. The telnet module is an alternative that > also does this, but only for telnet. Can't spawn a chess program on the > command line and interact with it using telnet module, but you can do it > using Expect (for all you telnet.pm zealots out there, that's the > difference) > > If you want to look at primitive code that represents this idea, then it > would look something like this: > > use Expect; > > $HOSTA=xx.xx.xx.1; > $HOSTB=xx.xx.xx.2; > $HOSTC=xx.xx.xx.3; > > $username="abc"; > $password="123"; > ># ------------ ># telnet to A ># ------------ > my $exp = Expect->spawn("telnet $HOSTA") or die "Cannot spawn telnet: $! > \n"; > $timeout=20; > expect($timeout, "login: "); > $exp->send("$username\n"); > expect($timeout, "password: "); > $exp->send("$password\n"); > $expect($timeout, '-re', "[%#>] $"); # $HOSTA prompt > ># ------------ ># telnet to B ># ------------ > $exp->send("telnet $HOSTB\n"); > expect($timeout, "login: "); > $exp->send("$username\n"); > expect($timeout, "password: "); > $exp->send("$password\n"); > $expect($timeout, '-re', "[%#>] $"); # $HOSTB prompt > ># ------------ ># telnet to C ># ------------ > $exp->send("telnet $HOSTC\n"); > expect($timeout, "login: "); > $exp->send("$username\n"); > expect($timeout, "password: "); > $exp->send("$password\n"); > $expect($timeout, '-re', "[%#>] $"); # $HOSTC prompt > > > Braindead simple example, but you should get the idea. Do a perldoc on > Expect.pm and print it out, go to staples and buy a binder, put it in > there and carry it around / put it on your desk at work also. If you > REALLY want to get nuts and rule the world with Expect, go out and buy > Don Libes most excellent O'Reilly book. Tcl is such a simple language, > that you would have no problem figuring enough of it out on the fly to > literally use this book as a supercharged reference for the Perl module, > that is, unless you're a Perl zealot and can't for religious reasons.. > although the perl module is not 100% translation, it's close enough for > government work (so the saying goes.) > > > Anyways, hope this helps you man. > > > > > > > Hailey Nguyen > <Hai...@Su...> To: > Chris Muth <mut...@mc...> Sent > by: cc: Hailey Nguyen > <Hai...@Su...>, > exp...@li...urc > exp...@li... > eforge.net Subject: Re: > [Expectperl-discuss] Nested telnet > sessions using Expect.pm module > 10/02/2003 04:11 PM > > > > > > > > Hi Chris, > >>>> First you will have to login to A. That involves what you have, plus >>>> you will have to $exp->expect() for whatever telnet responds with when >>>> it asks for the password. Then use a $exp->send() to send the > password. >>>> Then $exp->expect() for the prompt on A. Once you are logged into A, >>>> use a $exp->send() to call telnet $B on A to login to B, $exp->expect() >>>> for the password prompt, and then $exp->send() it. Once logged into B, >>>> do the same to login to C, and the same for D, and the same for ... > > Still struggling with this. As soon as I logged into B from A I lose > control of that session/connection. So $exp->send() won't do anything. > Did you write something like this before. Can I have an example? > > Note: A know B but doesn't know C - in another words, to get to C you > have to go through B. > > Thanks a million, > Hailey > > >>>>> >>>>> Please show me how to do nested telnet sessions using Expect.pm > module? >>>>> >>>>> 1- telnet to machine A >>>>> 2- from A to mcahine B >>>>> 3- from B to machine C >>>>> >>>>> ----- >>>>> use Expect; >>>>> >>>>> my $exp = Expect->spawn("telnet $somehost") >>>>> or die "Cannot spawn telnet: $!\n"; >>>>> >>>>> ... >>>>> >>>>> ----- >>>>> Your help is greatly appreciated. Please reply directly to me since >>>>> I am not on the alias. >>>>> > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > > |
From: <db...@CT...> - 2003-10-03 20:21:21
|
>>> Note: A know B but doesn't know C - in another words, to get to C you have >>> to go through B. Yes.. well, I guess it depends on what you're trying to say behind the words. Remember that you're spawning ONE process (or should be). Once you've done that and successfully logged into A, you should INVOKE telnet client on A to get to B, so there's no more "spawning" (from a perl module perspective), as B and C have no clue what the heck SPAWN is.. they just know what telnet is. Just imagine that you are invoking telnet on the command line from host to host to host, and that's ultimately what expects doing with the single telnet session you spawned to A. Imagine it that way and you should be able to see enough of what's going on to know how to use expect and code it. Remember that each time you hop, the STDOUT and STDERR channels get lashed together, and become STDIN to the thing that created it (parent.) They all get lashed together like the Alaskan pipeline, all the way back to your original spawned process in your expect script. In this daisy-chain telnet example you're trying to do, it is the only STDIN that your script should be dealing with. I don't know if that's the understanding you need, or if I'm confusing you more. Bottom line, If you can do it from the command line, i.e., telnet from A to B to C and so forth, then so can expect. If you can't do it, then neither can expect. It's that simple. All expect does is provide a way to automate the steps. The only difference between opening a process in Perl vs. Expect is that perl (by itself) cannot open a bi-directional pipe to a process. I.e., it can do this open (TELNET, " telnet $HOSTA | "); which would allow you to read from the session, or you can do this: open (TELNET, "| telnet $HOSTA "); to write to the process, but you cannot do both at the same time like this: open (TELNET, "| telnet $HOSTB | "); that's where Expect can help. The telnet module is an alternative that also does this, but only for telnet. Can't spawn a chess program on the command line and interact with it using telnet module, but you can do it using Expect (for all you telnet.pm zealots out there, that's the difference) If you want to look at primitive code that represents this idea, then it would look something like this: use Expect; $HOSTA=xx.xx.xx.1; $HOSTB=xx.xx.xx.2; $HOSTC=xx.xx.xx.3; $username="abc"; $password="123"; #------------ # telnet to A #------------ my $exp = Expect->spawn("telnet $HOSTA") or die "Cannot spawn telnet: $! \n"; $timeout=20; expect($timeout, "login: "); $exp->send("$username\n"); expect($timeout, "password: "); $exp->send("$password\n"); $expect($timeout, '-re', "[%#>] $"); # $HOSTA prompt #------------ # telnet to B #------------ $exp->send("telnet $HOSTB\n"); expect($timeout, "login: "); $exp->send("$username\n"); expect($timeout, "password: "); $exp->send("$password\n"); $expect($timeout, '-re', "[%#>] $"); # $HOSTB prompt #------------ # telnet to C #------------ $exp->send("telnet $HOSTC\n"); expect($timeout, "login: "); $exp->send("$username\n"); expect($timeout, "password: "); $exp->send("$password\n"); $expect($timeout, '-re', "[%#>] $"); # $HOSTC prompt Braindead simple example, but you should get the idea. Do a perldoc on Expect.pm and print it out, go to staples and buy a binder, put it in there and carry it around / put it on your desk at work also. If you REALLY want to get nuts and rule the world with Expect, go out and buy Don Libes most excellent O'Reilly book. Tcl is such a simple language, that you would have no problem figuring enough of it out on the fly to literally use this book as a supercharged reference for the Perl module, that is, unless you're a Perl zealot and can't for religious reasons.. although the perl module is not 100% translation, it's close enough for government work (so the saying goes.) Anyways, hope this helps you man. Hailey Nguyen <Hai...@Su...> To: Chris Muth <mut...@mc...> Sent by: cc: Hailey Nguyen <Hai...@Su...>, exp...@li...urc exp...@li... eforge.net Subject: Re: [Expectperl-discuss] Nested telnet sessions using Expect.pm module 10/02/2003 04:11 PM Hi Chris, >>> First you will have to login to A. That involves what you have, plus >>> you will have to $exp->expect() for whatever telnet responds with when >>> it asks for the password. Then use a $exp->send() to send the password. >>> Then $exp->expect() for the prompt on A. Once you are logged into A, >>> use a $exp->send() to call telnet $B on A to login to B, $exp->expect() >>> for the password prompt, and then $exp->send() it. Once logged into B, >>> do the same to login to C, and the same for D, and the same for ... Still struggling with this. As soon as I logged into B from A I lose control of that session/connection. So $exp->send() won't do anything. Did you write something like this before. Can I have an example? Note: A know B but doesn't know C - in another words, to get to C you have to go through B. Thanks a million, Hailey >>>> >>>> Please show me how to do nested telnet sessions using Expect.pm module? >>>> >>>> 1- telnet to machine A >>>> 2- from A to mcahine B >>>> 3- from B to machine C >>>> >>>> ----- >>>> use Expect; >>>> >>>> my $exp = Expect->spawn("telnet $somehost") >>>> or die "Cannot spawn telnet: $!\n"; >>>> >>>> ... >>>> >>>> ----- >>>> Your help is greatly appreciated. Please reply directly to me since >>>> I am not on the alias. >>>> ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
From: Hailey N. <Hai...@Su...> - 2003-10-03 01:23:09
|
I can't thank you enough! Made my day - wait my week actually! Thank You so much Chris, Hailey >> Did you write something like this before. Can I have an example? > Yes I did. Sure, here it is. > > This is more than an example, It is a fully working implementation of a > so called "looping login" scheme. It works for an arbitrary number of > hosts. It was also designed to work with ssh, and not telnet. You will > have to go through and make the relevant changes to make it work with > telnet. Optionally, you might consider using ssh -if possible-, as it is > more secure than telnet. > > This will log you into all of the given hosts and leave you with a $exp > that is valid on the final host. > > This is a subroutine. The usage explanation of it is at the bottom of > the code segment. > > I hope this helps. > |
From: Chris M. <mut...@mc...> - 2003-10-02 22:21:08
|
Hi, >Did you write something like this before. Can I have an example? Yes I did. Sure, here it is. This is more than an example, It is a fully working implementation of a so= called "looping login" scheme. It works for an arbitrary number of hosts. It was also designed to work= with ssh, and not telnet. You will have to go through and make the relevant changes to make it work= with telnet. Optionally, you might consider using ssh -if possible-, as it is more= secure than telnet. This will log you into all of the given hosts and leave you with a $exp= that is valid on the final host. This is a subroutine. The usage explanation of it is at the bottom of the= code segment. I hope this helps. -Chris Muth #### #### START OF CODE #### #!/usr/bin/perl5.8 -w use Expect; # for scripted I/O # req global; $exp, $number_of_hosts, $hostname[], $password[], sub multi_login { my($i,$j); for ($i=3D0;$i<$number_of_hosts;$i++){ if ($i=3D=3D0){ $exp->spawn("/usr/local/bin/ssh",$hostname[$i]); } else { $exp->send("/usr/local/bin/ssh ".$hostname[$i]."\n"); } $retval =3D $exp->expect(30,'-re','word:\s$','Connection refused','No= route to host','Name or service not known'); if (defined $retval){ if ($retval !=3D 1) { # $retval is 2 or 3. if ($retval =3D=3D 2){ # $retval is 2, "Connection refused". if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "connection refused for ".$hostname[$i]; $exp->hard_close(); exit 1; } else { if ($retval =3D=3D 3){ #$retval is 3, "No route to host". if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "there is no route to host ".$hostname[$i]; $exp->hard_close(); exit 1; } else { # $retval is 4, 'Name or sevice not known' if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "Name or service not known for host= ".$hostname[$i]; $exp->hard_close(); exit 1; } } } # $retval is 1, we got the password prompt. } else { # $retval is undefined, ssh didn't respond with anything= within 30 seconds. if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "ssh did not respond"; $exp->hard_close(); exit 1; } $exp->send($password[$i]."\n"); $retval =3D $exp->expect(30,'# ','Permission denied'); if (defined $retval){ if ($retval =3D=3D 2){ # $retval is 2, we got a permission denied= message. if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "permission denied for login to ".$hostname[$i]; $exp->hard_close(); exit 1; } # $retval is 1, we got the prompt. } else { # Got neither a prompt, nor a permission deined message. if ($i > 0){ for ($j=3D0;$j<$i;$j++){ $exp->send("logout\n"); } } print "error on login to ".$hostname[$i]; $exp->hard_close(); exit 1; } } } # instiantiate an Expect object that we will use. $exp =3D new Expect; $exp->raw_pty(1); # for use by multi_login(), how many hosts to login to. $number_of_hosts =3D 3; # List all of the hosts to login to. Start at 0. $hostname[0] =3D 'host0'; $hostname[1] =3D 'host1'; $hostname[2] =3D 'host2'; # List all of the passwords for the hosts to be logged into. Again, start= at 0. $password[0] =3D 'pass0'; $password[1] =3D 'pass1'; $password[2] =3D 'pass2'; # Call multi_login(), it will use $exp, $number_of_hosts, $hostname[], and= $password[]. multi_login(); # From here on out, $exp is valid on hostname[<max>]. # Just use it as normal. # Modify the prompt to something easy to match, and easy on bandwidth. $exp->send("PS1=3D\"# \"\nexport PS1\n"); $exp->expect(30,'# '); $exp->expect(30,'# '); $exp->send("ls -l\n"); $exp->expect(30,'# '); # this will make expect wait, as sleep() does not work with expect scripts. $exp->expect(5,'this call will make expect sleep'); $exp->hard_close(); print "\n"; exit 0; ##### ##### END OF CODE ##### |
From: Hailey N. <Hai...@Su...> - 2003-10-02 20:13:10
|
Hi Chris, >>> First you will have to login to A. That involves what you have, plus >>> you will have to $exp->expect() for whatever telnet responds with when >>> it asks for the password. Then use a $exp->send() to send the password. >>> Then $exp->expect() for the prompt on A. Once you are logged into A, >>> use a $exp->send() to call telnet $B on A to login to B, $exp->expect() >>> for the password prompt, and then $exp->send() it. Once logged into B, >>> do the same to login to C, and the same for D, and the same for ... Still struggling with this. As soon as I logged into B from A I lose control of that session/connection. So $exp->send() won't do anything. Did you write something like this before. Can I have an example? Note: A know B but doesn't know C - in another words, to get to C you have to go through B. Thanks a million, Hailey >>>> >>>> Please show me how to do nested telnet sessions using Expect.pm module? >>>> >>>> 1- telnet to machine A >>>> 2- from A to mcahine B >>>> 3- from B to machine C >>>> >>>> ----- >>>> use Expect; >>>> >>>> my $exp = Expect->spawn("telnet $somehost") >>>> or die "Cannot spawn telnet: $!\n"; >>>> >>>> ... >>>> >>>> ----- >>>> Your help is greatly appreciated. Please reply directly to me since >>>> I am not on the alias. >>>> |
From: Hailey N. <Hai...@Su...> - 2003-10-01 20:33:58
|
Hi Chris, Thanks so much for the help! I was able to telnet into the hostA then the next one it keeps looping around the statement below and won't quit. If I take out the "\n"" character it won't loop but it won't go further either. $fh->send("telnet $hostsB\n"; Help Help Help ... thanks again. H ----------- !/bin/perl use Expect; $Expect::Log_Stdout = 1; # variables define here # ... my $exp = Expect->spawn("telnet $hostA") or die "Cannot spawn telnet: $!\n"; my $spawn_ok; $exp->log_file("testlog"); $exp->expect($timeout, [ qr'login: $', sub { $spawn_ok = 1; my $fh = shift; $fh->send("$username\n"); exp_continue; } ], [ 'Password: $', sub { my $fh = shift; print $fh "$password\n"; exp_continue; } ], [ '# $', sub { $spawn_ok = 1; my $fh = shift; $fh->send("telnet $hostB\n"); <================ exp_continue; } ], [ 'login: $', sub { my $fh = shift; print $fh "$username\n"; exp_continue; } ], [ 'Password: $', sub { my $fh = shift; print $fh "$password\n"; exp_continue; } ], [ eof => sub { if ($spawn_ok) { die "ERROR: premature EOF in login.\n"; } else { die "ERROR: could not spawn telnet.\n"; } } ], [ timeout => sub { die "No login.\n"; } ], '-re', qr'[#] $' # wait for shell prompt, then exit expect ); $exp->hard_close(); ------------------------- > > First you will have to login to A. That involves what you have, plus you > will have to $exp->expect() for whatever telnet responds with when it > asks for the password. Then use a $exp->send() to send the password. > Then $exp->expect() for the prompt on A. Once you are logged into A, use > a $exp->send() to call telnet $B on A to login to B, $exp->expect() for > the password prompt, and then $exp->send() it. Once logged into B, do > the same to login to C, and the same for D, and the same for ... > > -Chris > > > On 10/1/03 at 11:07 AM Hailey Nguyen wrote: > >> Hi, >> >> Please show me how to do nested telnet sessions using Expect.pm module? >> >> 1- telnet to machine A >> 2- from A to mcahine B >> 3- from M to another machine C >> >> ----- >> use Expect; >> >> my $exp = Expect->spawn("telnet $somehost") >> or die "Cannot spawn telnet: $!\n"; >> >> ... >> >> ----- >> Your help is greatly appreciated. Please reply directly to me since >> I am not on the alias. >> >> Hailey. >> >> > |
From: Chris M. <mut...@mc...> - 2003-10-01 19:05:56
|
Hey, First you will have to login to A. That involves what you have, plus you= will have to $exp->expect() for whatever telnet responds with when it asks for the password. Then use a= $exp->send() to send the password. Then $exp->expect() for the prompt on A. Once you are logged into A, use a= $exp->send() to call telnet $B on A to login to B, $exp->expect() for the password prompt, and then $exp->send() it. Once= logged into B, do the same to login to C, and the same for D, and the same for ... -Chris On 10/1/03 at 11:07 AM Hailey Nguyen wrote: >Hi, > >Please show me how to do nested telnet sessions using Expect.pm module? > >1- telnet to machine A >2- from A to mcahine B >3- from M to another machine C > >----- >use Expect; > >my $exp =3D Expect->spawn("telnet $somehost") > or die "Cannot spawn telnet: $!\n"; > >... > >----- >Your help is greatly appreciated. Please reply directly to me since >I am not on the alias. > >Hailey. > > |