Search code examples
perlunixglusterfs

Entering `y` automatically when encountering many Unix prompts


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";`

Solution

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