Need to know about send command of Expect package.Very urgent!!!!

View: New views
2 Messages — Rating Filter:   Alert me  

Need to know about send command of Expect package.Very urgent!!!!

by Preeti B :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

by Amarnath Madan Mohan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

 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();



Date: Tue, 18 Dec 2007 16:35:43 +0530
From: preeti.bn@...
To: expectperl-discuss@...
Subject: [Expectperl-discuss] 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


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
LightInTheBox - Buy quality products at wholesale price!