From owner-freebsd-questions@FreeBSD.ORG Wed Oct 1 13:53:05 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BCD1A1065697 for ; Wed, 1 Oct 2008 13:53:05 +0000 (UTC) (envelope-from steve@ibctech.ca) Received: from ibctech.ca (v6.ibctech.ca [IPv6:2607:f118::b6]) by mx1.freebsd.org (Postfix) with SMTP id 52EAA8FC1F for ; Wed, 1 Oct 2008 13:53:05 +0000 (UTC) (envelope-from steve@ibctech.ca) Received: (qmail 23767 invoked by uid 89); 1 Oct 2008 13:54:18 -0000 Received: from unknown (HELO ?IPv6:2607:f118::5?) (steve@ibctech.ca@2607:f118::5) by 2607:f118::b6 with ESMTPA; 1 Oct 2008 13:54:18 -0000 Message-ID: <48E380C4.4090304@ibctech.ca> Date: Wed, 01 Oct 2008 09:53:08 -0400 From: Steve Bertrand User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: "freebsd-questions@freebsd.org Questions -" X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Using global environment variables inside a subshell X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2008 13:53:05 -0000 Hi everyone, I've fudged together a quick disk space monitor that I will run from cron. Running the script works fine from the command line, but when I run it from cron, the environment variable is empty. Can someone point out the err of my ways?: #!/bin/sh /bin/df | \ /usr/bin/awk '{if($5 ~ "%" && $6 !~ "proc") {used=$5} else {used=""}; \ sub(/%/, "", used); \ if(used > 95) print $6 " is at " used"% on "ENVIRON["HOSTNAME"]"!"}' | \ mail -s "Disk usage action required" email@addr.com Cheers! Steve