pijush has asked for the wisdom of the Perl Monks concerning the following question:
and here is the code to handle expectContinue with installation|y Do you wish to continue|y Press RETURN when ready| license|q Do you agree to the terms of the license agreement|y Enter the installation directory|/xxxx
How can I send the answer of last question?open (input, "< QA.txt") while(<input>) { chomp; # no newline s/\#.*//; # no comments s/^\s+//; # no leading white space s/\s+$//; # no trailing white next unless length; # anything left? push (@InputArray, $_); } close (input); my (@Question,@Answer); #Call expect to install my $Install = Expect->spawn("./$FileName") ; for($Index = 0; $Index <= $#InputArray; $Index++) { ($Question[$Index],$Answer[$Index]) = split(/\|/,$InputArray[$Index] +); } for($Index = 0; $Index <= $#InputArray; $Index++) { unless ($Install->expect(200,'-re',$acQuestion[$Index])) { die ("Error::". $Install->exp_error() . "\n"); } print $Install "$Answer[$Index]"; print $Install "\r"; sleep (2); } #close the expect $Install->hard_close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help needed for expect module!!
by pijush (Scribe) on Dec 20, 2003 at 05:30 UTC |