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= |