From owner-freebsd-questions@freebsd.org Tue Jan 31 17:11:53 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E1EBCCAEAF for ; Tue, 31 Jan 2017 17:11:53 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from inet08.hamilton.harte-lyne.ca (inet08.hamilton.harte-lyne.ca [216.185.71.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "inet08.hamilton.harte-lyne.ca", Issuer "CA_HLL_ISSUER_2016" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 5B30F1E6B for ; Tue, 31 Jan 2017 17:11:53 +0000 (UTC) (envelope-from byrnejb@harte-lyne.ca) Received: from localhost (localhost [127.0.0.1]) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTP id 3F4F162223 for ; Tue, 31 Jan 2017 12:11:51 -0500 (EST) X-Virus-Scanned: amavisd-new at harte-lyne.ca Received: from inet08.hamilton.harte-lyne.ca ([127.0.0.1]) by localhost (inet08.hamilton.harte-lyne.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZzIgH8EPO3qB for ; Tue, 31 Jan 2017 12:11:49 -0500 (EST) Received: from webmail.harte-lyne.ca (inet04.hamilton.harte-lyne.ca [216.185.71.24]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by inet08.hamilton.harte-lyne.ca (Postfix) with ESMTPSA id E2A8A6216C for ; Tue, 31 Jan 2017 12:11:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harte-lyne.ca; s=dkim_hll; t=1485882709; bh=OESJaRdAui4ikiei8IF2VEJKykgOb1i9Wq93g7EfFPQ=; h=In-Reply-To:References:Date:Subject:From:To:Reply-To; b=pQboyaILoobKn6i52J7pUFaLqBN0V8w1NSGiVbUG/pEDOlvEuUMI9f/CJpwQDS22p Wynkx92mQY3am8KpxW8o1aGdpMc5pliX8pulP7ELLfKXdTqqDppaKUHG0EhvwfrZ8n mWmEzzJIQnNK8jheIwQ54dfOy2ZrhDrCXnPoHIqZNEc2L4wvyxaxkiLd2QSCZd1lm5 Mi872nWc8qL3PMCPJQtHxATNMGqrF+D2TNs2VtETzlz3ACoOFT31jmvoUzvYhSbflp qXBd78KLq/kVgvjqD+8scqPzQzdJx/4ZgwlXhooyoL/qcxrLw55kkJy4zMqASoLelK H08SuIIvSu0hw== Received: from 216.185.71.44 (SquirrelMail authenticated user byrnejb_hll) by webmail.harte-lyne.ca with HTTP; Tue, 31 Jan 2017 12:11:49 -0500 Message-ID: In-Reply-To: <20170131161824.a9f1ef46.freebsd@edvax.de> References: <20170131161824.a9f1ef46.freebsd@edvax.de> Date: Tue, 31 Jan 2017 12:11:49 -0500 Subject: Re: Variable assignment in sh From: "James B. Byrne" To: freebsd-questions@freebsd.org Reply-To: byrnejb@harte-lyne.ca User-Agent: SquirrelMail/1.4.22-4.el6 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jan 2017 17:11:53 -0000 On Tue, January 31, 2017 10:18, Polytropon wrote: > On Tue, 31 Jan 2017 10:06:37 -0500, James B. Byrne via > freebsd-questions wrote: >> Why am I getting this result when I attempt a simple variable >> assignment in the default sh? >> >> # ENV=$HOME/.shrc; export ENV >> ENV=/root/.shrc: Command not found. >> export: Command not found. >> >> This example is taken verbatim from the sh manpage provided with >> FreeBSD. > > This looks like you're running a sh command inside csh. > Note that the C shell (FreeBSD's default interactive shell) > does variable assignments differently: > > setenv ENV /root/.shrc > > set FOO = 1 > > See "man csh" for details. > > The command you've presented looks like it would belong into > a shell script (FreeBSD's default scripting shell)... > I note that root is configured in FreeBSD with a default shell of /bin/csh and that the user toor has no default shell specified at all notwithstanding having a Real Name of 'Bourne-again Superuser'. I checked several of our FreeBSD hosts and all have the same configuration for root and toor so I infer that this is how FreeBSD is shipped. My problem was running a status check command from cron. Having noted that it was failing I tried testing the command having logged on to the FreeBSD server as root (using ssh with certificates). This is the user with which cron is configured to execute this particular command. I am somewhat puzzled by your comment: > a shell script (FreeBSD's default scripting shell) What does this mean exactly? Is not CSH a shell? I thought that the shell used in cron was the shell of the user associated with the crontab file? What is cron's default shell otherwise? In any case, I now have set the shell in the root crontab file explicitly to /usr/local/bin/bash in hopes of avoiding this problem in the future. -- *** e-Mail is NOT a SECURE channel *** Do NOT transmit sensitive data via e-Mail Do NOT open attachments nor follow links sent by e-Mail James B. Byrne mailto:ByrneJB@Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3