Hi Ken,

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.

--Sriram

In reply to Re^2: Need help on perl Expect Module by sriram83.life
in thread Need help on perl Expect Module by sriram83.life

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.