0

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";`
onebree
  • 1,853
  • 1
  • 17
  • 44
aditya
  • 149
  • 1
  • 3
  • 15
  • [Expect](http://search.cpan.org/~rgiersig/Expect-1.15/Expect.pod) is a general solution to interact in your Perl script with other interactive programs. – Lee Duhem Feb 22 '14 at 04:57
  • You appear to be missing some quotes. That's not valid Perl code. – nobody Apr 08 '14 at 15:58

2 Answers2

2

Try piping yes into the command

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

A working example from my code!

yes | rm *.txt
BillyBigPotatoes
  • 1,330
  • 11
  • 23
0

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.

titanofold
  • 2,852
  • 1
  • 15
  • 21
earino
  • 2,885
  • 21
  • 20