I want to install Perl packages automatically using a Perl script. The code I am using is
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use CPAN;
eval "use JSON"
or do {
CPAN::install("JSON");
};
eval "use Net::Address::IP::Local"
or do {
CPAN::install("Net::Address::IP::Local");
};
eval "use Net::OpenSSH"
or do {
CPAN::install("Net::OpenSSH");
};
eval "use Net::SCP::Expect"
or do {
CPAN::install("Net::SCP::Expect");
};
During the script runs, it asks for prompt like yes or no, passwords, etc. How to handle these prompt automatically? I have to deploy it on many servers so I had to automate it.
I got a solution for this that when there is a prompt in between installation of any package either it is automated or manual the prompt got timed out automatically after 15secs, and further installation continues as usual. and also we can give yes in pipe (|
) if there is prompt for "yes" only.