I want to write a script that extracts files in directories and their subdirectories recursively.I have used File::Find module to use wanted() subroutine to extract files recursively.While it recursively extracts,some duplicate files are appearing and asking for prompt to replace or rename. Here is the example prompt.
replace META-INF/MANIFEST.MF? [y]es, [n]o, [A]ll, [N]one, [r]ename:
Every time it appears,script has to send "A" reply to the prompt and it has to continue as i need to extract hundreds of files and get the required file.Can any one give me suggestions on how to write this using perl Expect?
Here is my code which uses File::Find module to find files recursively and perform some actions.
find( { wanted => \&wanted, }, @dirs); sub wanted { my $depth = $File::Find::dir =~ tr[/][]; return if $depth < $min_depth; if ( $File::Find::name =~ m/.zip$|file.*?$/ ) { print "I am extracting zip file : $File::Find::name\n"; &execute_command("unzip $File::Find::name"); #At this point it asks for prompt,i need to make it accept reply +automatically. #execute_command is a subroutine written in another module which +uses fork and exec to execute a shell command. elsif ( $File::Find::name =~ m/.gz$/ ) { &execute_command("gunzip $File::Find::name"); } }
Your help is much appreciated.
In reply to Need help on perl Expect Module by sriram83.life
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |