문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top