Have you considered using the Expect.pm module?
It basically is a copy of the Tcl based expect command:
It is designed explicitly for interacting with programs.
Вопрос
I have to automate some prompt-interactions with GlusterFS using Perl. I made a module delete()
that automatically deletes gluster volume; however, it asks (y/n)
for each volume. How can I provide this answer in advance? My script below also seems to hang during execution.
`my $vol_name = params->{vol_name};
gluster volume stop $vol_name ;
my $string = gluster volume delete $vol_name;
print "$string\n\n\n";`
Решение 2
Have you considered using the Expect.pm module?
It basically is a copy of the Tcl based expect command:
It is designed explicitly for interacting with programs.
Другие советы
Try piping yes into the command
my $string = yes | gluster volume delete $vol_name;
A working example from my code!
yes | rm *.txt