Re: [Hampshire] new user - setenv source question

Top Page
Author: Hugo Mills
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] new user - setenv source question

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x580c8100.hantslug.org.uk.31205': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Thu May 13 12:45:43 2010 BST
gpg: using DSA key 20ACB3BE515C238D
gpg: Can't check signature: No public key
On Thu, May 13, 2010 at 12:31:34PM +0100, Anna Scott wrote:
> I am new to using Linux and am trying to set the environment varibles
> using the setenv and source commands. So this is probably an easy one to
> answer!
>
> I get the following error when trying set the source command:
>
> $ source $Z7PATH/lib/Z7_cshrc
> /home/anna/Zebulon/Z8.4.3/lib/Z7: No such file or directory.
>
> I have already set $Z7PATH as an environment variable. However it seems
> to be looking for Z7 not Z7_cshrc?


First off, if you want to examine the current value of an
environment variable, you can use echo:

$ echo $Z7PATH

This will print out the value of the variable for you.

Secondly, it looks like you're running a shell script intended for
the C shell (as it's called Z7_cshrc), and Linux defaults to using the
Bourne Again Shell (bash). The syntax of the two is significantly
different, and a csh script won't run on bash, unless it's *very*
simple.

The solution in most cases is to run the script through csh
instead:

$ csh $Z7PATH/lib/Z7_cshrc

However, if the script in question is intended to set environment
variables (as the "rc" suffix would imply, and the fact that you're
using "source" to read it), that won't work, because it'll set the
environment variables in the environment of the C shell you've just
run, and they get forgotten when that shell stops.

Actual solutions... either:

1) Start up a C shell first, and then run everything from within
there:

$ csh
> source $Z7PATH/lib/Z7_cshrc


*or*

2) Rewrite the Z7_cshrc script to use bash syntax instead of csh
syntax. Where csh uses:

setenv FOO=bar

bash uses:

export FOO=bar

Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
    --- Questions are a burden, and answers a prison for oneself. ---