I tried use strict and it wants me to declare all my variables, not a very practical optionWell, 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.
In reply to Re^3: print question
by rovf
in thread print question
by bp4a
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |