Snippet of what I understand from your requirement: parag@ubuntu-studio:~$ cat app #!/bin/bash if [ $# -ne 1 ] then echo -e "Invalid number of input\nUsage: app <input>" exit 1 else input=$1 fi
if [ $input != "register" ] then echo "Invalid choice" exit 1 fi echo "mac" echo "windoze" echo "Select the server to register:" echo -n "ubuntu(default):" read os case $os in mac) echo "rich spoiled brat" ;; windoze) echo "old arrogant user" ;; ubuntu) echo "smart sexy nerd" ;; *) echo "invalid choice" ;; esac parag@ubuntu-studio:~$ parag@ubuntu-studio:~$ cat expect.pl use strict; use warnings; use Expect; my $app = "./app register"; my @oss = qw/ubuntu mac windoze/; my $choice = $oss[rand @oss]; my $exp = new Expect; $exp->spawn($app) or die "$!\n"; $exp->expect(15,[ qr/default/ => sub { my $ch = shift; print $ch "$choice\n"; exp_continue; } ] ); parag@ubuntu-studio:~$ Is this what you want? ~Parag On Mon, Jan 17, 2011 at 10:19 PM, Zaheer <zaheer...@gmail.com> wrote: > Hi, > I am trying to automate a cli application that has multiline output. I > want to be able to grep for this multi line output as single string > using Expect module and send some keys as input. > > The cli would be something like > > bash-3.00# /opt/myapp/bin/app register > > 1) someservername(1) > 2) someoptionalserver(2) > Select destination server or enter full URL for alternate server > [somedefaultserver(3)]: > > How can I do this using Expect? > > Thanks in advance.. > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/