|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Need to know about send command of Expect package.Very urgent!!!!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
------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Expectperl-discuss mailing list Expectperl-discuss@... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
|
|
Re: Need to know about send command of Expect package.Very urgent!!!!Hope below script helps. #!/usr/local/bin/perl use Expect; my $obj = new Expect->spawn(ssh, @params); my $prompt = "#"; my $timeout = 10; print $ARGV[0],"\n"; my $passwd = " "; # define ur passwd here my @params = qw( -l root); push(@params,$ARGV[0]); my $obj = 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=# \r\n"); }); #sets the Primary 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 = <STDIN>; chomp($input); $obj->expect($timeout, '-re', $prompt, sub { $obj->send("$input\r\n") }); #sending keyboard input. $obj->interact();
Fly HYD-BLR for Rs.499 Log on to MakeMyTrip! Check it out! ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Expectperl-discuss mailing list Expectperl-discuss@... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |
| Free Forum Powered by Nabble | Forum Help |