I tried use strict and it wants me to declare all my variables, not a very practical option
Well, IMHO, using strict (and warnings!) *is* very practical, because you will catch a lot of errors early. What's so bad in declaring your variables?

Aside from this, let's play a bit Sherlock Holmes: Assume that the error really occurs in the piece of code you have shown. We know that the error is issued by sh, hence some sh script must be run. This could mean that you either happen to have a shell script called 'grep' or 'df' in your path, which is invoked instead of the "standard program" - you can try it out by using absolute pathes to those -, or that you shell is implicitly sourcing some script when starting.

You did not tell us about which sh you are using. For example, sh under Linux is typically linked to bash, but has a different startup behaviour than "normal" bash. In particular, if your program is attached to a terminal, bash invoked as sh would act as an interactive shell, and would look for an environment variable named ENV, and would execute the file named in $ENV as shell script. Hence you might want to check whether you have such an environment variable.

If this doesn't bring any insight either, you could replace your external df | grep by a shell script on your own (for example, a #!bash --norc to ensure that nothing is sourced without your permission), and find out whether the error message occurs before, during, or after execution of this script.

For the safe side, I would also set $|=1 in your program, although from what I see from your code, this should not be a buffering problem.

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^3: print question by rovf
in thread print question by bp4a

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.