in reply to Re: invoke shell with `` failed
in thread invoke shell with `` failed

This doesn't excuse not telling us what $dir contains (or even rule it out), but it seems the error is coming from Perl code, not from the shell. That's most curious, and I'm wondering about a false positive. But since you didn't provide us the code that issues the error, can't tell.

Replies are listed 'Best First'.
Re^3: invoke shell with `` failed
by jiangliguo (Initiate) on Apr 15, 2009 at 06:02 UTC
    following is my script for space detect here the dir is: "/slowfs/hspice01/liguoj/performance/MT4/Rundir/Tue/RHEL4", and will not change during runtime.
    detect_disk() will invoke many times, the problem is during the first several times it run correct, but then failed.
    sub detect_disk { my ($flag, $dir) = @_; my $available_space = `df $dir`; my @array = split(/\s+/, $available_space); $available_space = $array[10]; if ($flag eq 'entry' and $available_space < 6000000) { print ("NOTICE: The left space of $dir is $available_space (KB +), please make sure enough space is available for the regresssion.\n\ +n"); } elsif ($flag eq 'routine' and ($available_space < 1000000)) { print ("NOTICE: The left space of $dir is $available_space (KB +), regression will waiting!\n"); sleep 60; while ($available_space < 1000000) { # send_mail($mail_list, $report_title, $report_file); $available_space = `df $dir`; @array = split(/\s+/, $available_space); $available_space = $array[10]; sleep 60; } } }

      After some experimentation, I've managed to duplicate this error message -- but (on my system) it only happens when $dir is more than about two megabytes long! Are you sure $dir never changes?

      The error is coming from the operating system; it can't be trapped with eval like I'd expected. However, you can determine whether the command succeeded by checking $?, which will be 0 if it worked and something else if it didn't. So I suggest what you do is change your code slightly:

      my $available_space = `df $dir`; if ($? != 0) { warn "df failed: command was `df $dir`"; }

      (and the equivalent in the other place where you use ``).

      That should tell you exactly what is being considered "too long".