Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2017 12:11:49 -0500
From:      "James B. Byrne" <byrnejb@harte-lyne.ca>
To:        freebsd-questions@freebsd.org
Subject:   Re: Variable assignment in sh
Message-ID:  <b553c644fccc211f9658b31cfe65e8a0.squirrel@webmail.harte-lyne.ca>
In-Reply-To: <20170131161824.a9f1ef46.freebsd@edvax.de>
References:  <b831bd9e40321e59910ea8913c7a6302.squirrel@webmail.harte-lyne.ca> <20170131161824.a9f1ef46.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b553c644fccc211f9658b31cfe65e8a0.squirrel>