Question

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";`
Was it helpful?

Solution 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.

OTHER TIPS

Try piping yes into the command

my $string = yes | gluster volume delete $vol_name;

A working example from my code!

yes | rm *.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top