Here is my execute_command code which just executes a command in shell and returns its exit status.
sub execute_command { my($command) = @_; return &execute_command_rc(0,$command); } #Same, but can specify a return code to check for success sub execute_command_rc { my $expectedrc = $_[0]; my $command = $_[1]; my $pid = &my_fork($command); my $returned_pid = waitpid($pid,0); my $status = $?; &log_and_exit("no child procs to collect?????",$failure) if ($returned_pid == -1); &log_and_exit("returned pid: $returned_pid should have been $pid",$f +ailure) if ($returned_pid != $pid); # tim thinks perl should have macros like WEXITSTATUS my $exit_value = $status >> 8; my $signal_num = $status & 127; my $dumped_core = $status & 128; &log_message("$command exited with status: $exit_value (instead of $ +expectedrc)") if ($exit_value != $expectedrc); &log_message("$command killed by signal: $signal_num") if ($signal_num); &log_message("$command dumped core") if ($dumped_core); # emulate bash behavior. if process is killed, then return (128 | si +gnal no.) return ($signal_num | 128) if ($signal_num); return $exit_value; }
log_message and log_and_exit sub routines are just logging sub routines.They are not for this context.
My main focus here is,to unzip continuously and recursively and replace duplicate files that get unzipped. Thanks for your suggestion Ken, unzip -o helps overwrite files with out prompt.
--SriramIn reply to Re^2: Need help on perl Expect Module
by sriram83.life
in thread Need help on perl Expect Module
by sriram83.life
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |