Problem with BASH and [ ! -t 0 ] test.
Chuck Swiger
cswiger at mac.com
Wed Feb 18 12:47:02 PST 2009
On Feb 18, 2009, at 12:29 PM, GESBBB wrote:
> I am a little confused. I believe the problem is with the "if [ ! -t
> 0 ]" statement. I tried to redirect the error message; however, it
> still appears in the email sent by CRON. I tried using this
> statement instead: if ( ! tty -s &> /dev/null ) and "if ( ! tty -s )
> &> /dev/null"; however, they also produce an error message although
> the function does work correctly. Is this just something I should
> just ignore, or is there a way to stop the message from being sent
> in the CRON report?
For Bourne shell, classic /bin/sh, and related shells (zsh, ksh), you
can use something like:
case $- in
*i*)
# do stuff for an interactive shell
echo "interactive"
;;
*)
# not interactive
echo "not interactive"
;;
esac
Regards,
--
-Chuck
More information about the freebsd-questions
mailing list