LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-21-2010, 12:27 PM   #1
Azazwa
Member
 
Registered: Mar 2009
Distribution: Fedora 8, Ubuntu 9.10, SuSE 10, Fedora 14
Posts: 98

Rep: Reputation: 15
Environment variables not being set correctly


Hi!

I'm very confused about this. The $g09root is picked up ( in both the csh and the bash), but not the $GV_DIR or the $GAUSS_SCRDIR. I guess it's some stupid error, but it is highly frustrating.

Here is the .profile file:
Quote:
# To make use of this feature, simply uncomment one of the lines below or
# add your own one (see /usr/share/locale/locale.alias for more codes)
#
#export LANG=de_DE.UTF-8 # uncomment this line for German output
#export LANG=fr_FR.UTF-8 # uncomment this line for French output
#export LANG=es_ES.UTF-8 # uncomment this line for Spanish output


# Some people don't like fortune. If you uncomment the following lines,
# you will have a fortune each time you log in ;-)

#if [ -x /usr/bin/fortune ] ; then
# echo
# /usr/bin/fortune
# echo
#fi

export g09root="/code/gaussian09"
export GAUSS_SCRDIR="/chemistry/users/$USER/gaussianScratch"
export GV_DIR="$g09root/gv"
export gaussian_path "\${g09root}/g09"

. $g09root/g09/bsd/g09.profile
unset gaussian_path
and the .login:
Quote:
setenv g09root "/code/gaussian09"
setenv GAUSS_SCRDIR "/chemistry/users/compchem/gaussianScratch"
setenv GV_DIR "${g09root}/gv"
setenv gaussian_path "${g09root}/g09"
source $g09root/g09/bsd/g09.login
unset gaussian_path
Some output:
Quote:
users/compchem> echo $g09root
/code/gaussian09
users/compchem> echo $GV_DIR
GV_DIR: Undefined variable.
users/compchem> echo $GAUSS_SCRDIR
GAUSS_SCRDIR: Undefined variable.
users/compchem> /bin/bash
compchem@b104pc110:~> echo $g09root
/code/gaussian09
compchem@b104pc110:~> echo $GV_DIR
csh is the default shell.

What have I missed?

Thanks!
 
Old 06-22-2010, 02:46 AM   #2
tommyttt
Member
 
Registered: Oct 2009
Location: Federal Way, WA
Distribution: openSUSE 11.4 x86_64, openSuSE 12.1, Fedora 15
Posts: 207

Rep: Reputation: 34
Quote:
Originally Posted by Azazwa View Post
Hi!

I'm very confused about this. The $g09root is picked up ( in both the csh and the bash), but not the $GV_DIR or the $GAUSS_SCRDIR. I guess it's some stupid error, but it is highly frustrating.

Here is the .profile file:


and the .login:


Some output:


csh is the default shell.

What have I missed?

Thanks!
I have only used bash as my shell so take this with a grain of salt. It appears as though you haven't declared the variables. For example:
Code:
setenv (const char *GV_DIR "${g09root}/gv")
See the manpage for setenv for more help.

Tom
 
Old 06-22-2010, 02:54 AM   #3
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,960

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
I might be wrong, but it looks like you're missing some curly brackets:

Code:
export g09root="/code/gaussian09"
export GAUSS_SCRDIR="/chemistry/users/${USER}/gaussianScratch"
export GV_DIR="${g09root}/gv"
 
Old 06-22-2010, 03:32 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by rkelsen View Post
I might be wrong, but it looks like you're missing some curly brackets:

Code:
export g09root="/code/gaussian09"
export GAUSS_SCRDIR="/chemistry/users/${USER}/gaussianScratch"
export GV_DIR="${g09root}/gv"
"Curly brackets" are not necessary in those places; they are not wrong but they are not necessary because the "/" after each is not a valid bash variable name character so terminates the name.
 
Old 06-22-2010, 04:21 AM   #5
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
May I ask what's this for?
Code:
export gaussian_path "\${g09root}/g09"
... Also why quote $ with \?
 
Old 06-22-2010, 04:21 AM   #6
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 805

Rep: Reputation: 186Reputation: 186
While you have exported "g09root" you haven't declared it before using it in other (subsequent) exports.

So, replace
Quote:
export g09root="/code/gaussian09"
with
Quote:
g09root="/code/gaussian09"
export g09root="/code/gaussian09"
or
Quote:
g09root="/code/gaussian09"
export g09root
 
Old 06-22-2010, 04:41 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Actually the file .profile is not read by C-shell, nor it follows the C-shell syntax so that you can safely ignore it. First a question: do you use the older shell /bin/csh or is it aliased (linked) to /bin/tcsh? Please, try:
Code:
ls -l `which csh`
or better
Code:
echo $version
Then you have to check if there are some other configuration files that can be sourced at login, for example ~/.tcshrc and/or ~/.cshrc. Eventually look at their content and try to determine if the shell source them before or after ~/.login.

Is it possible that some variables are unset by $g09root/g09/bsd/g09.login? What purpose does it serve?

Last edited by colucix; 06-22-2010 at 05:37 AM.
 
Old 06-23-2010, 08:17 AM   #8
Azazwa
Member
 
Registered: Mar 2009
Distribution: Fedora 8, Ubuntu 9.10, SuSE 10, Fedora 14
Posts: 98

Original Poster
Rep: Reputation: 15
Hi!

@colucix:
Code:
compchem@b104pc110:~> ls -l `which csh`
lrwxrwxrwx 1 root root 9 2010-04-26 18:41 /usr/bin/csh -> /bin/tcsh
users/compchem> echo $version
tcsh 6.14.00 (Astron) 2005-03-25 (x86_64-suse-linux) options wide,nls,lf,dl,al,kan,sm,color,filec
There is only an existing .bashrc not a .cshrc or .tcshrc, so I guess my only worry is .login.

Quote:
Is it possible that some variables are unset by $g09root/g09/bsd/g09.login? What purpose does it serve?
It is used by the application software and as far as I can see it sets some more environment variables (apart form $g09root, $GAUSS_SCRDIR and $GV_DIR) but it doesn't reset anything.

@AnanthaP
Thank you! What you said makes sense. I changed the .profile accordingly and everything seems fine now (even with the csh / tcsh )

@konsolebox
I'm not sure. It was in someone else's notes and it's probably a useless remnant. I will delete it and see what happens. (Probably nothing comparable to a train-smash...)

Thank you to the other contributers as well!

There is another issue, (and I think it is related to these env var's, otherwise I would've started a new thread):

There are actually 2 application programs, the one does the calculations, and the other is the viewer. I can start the calculation program from anywhere, but not the viewer. With the viewer I actually have to be in the directory where the script is kept, and this is slightly frustrating.

So, shouldn't I be able to run the viewer from any directory if my env is set correctly?

Look here:
Quote:
gaussian09/gv> ls
bin gv5.key gview.csh gvref lib Set_File_Protection.csh
data gview gview.exe help READMEs xglinfo
If I say ./gview being in the directory as above, then all is fine, but otherwise it doesn't recognise the command.

Must I add something to the PATH, or what?

Thanks!
;-)
 
Old 06-23-2010, 08:50 AM   #9
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by Azazwa View Post
I changed the .profile accordingly and everything seems fine now (even with the csh / tcsh)
Hi. Glad to see it works now. Anyway, take in mind that $HOME/.profile is truly ignored by the C-shell (unless the system administrator has disposed differently) and the export built-in is not a C-shell standard.
Quote:
Originally Posted by Azazwa View Post
Must I add something to the PATH?
Yes. It is the most straightforward method.

Cheers!

Last edited by colucix; 06-23-2010 at 08:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
could not set the environment variables correctly JimOrJoe Programming 4 05-15-2008 06:15 AM
Setting KDE environment variables correctly lykwydchykyn Debian 1 03-27-2006 05:31 PM
how do i set environment variables? guitarfella Slackware 2 12-05-2004 12:05 AM
How to set environment variables anjaan Linux - General 3 06-10-2004 03:04 PM
Help with the currently set environment variables!! apoc013 Linux - Newbie 6 01-21-2004 02:28 AM


All times are GMT -5. The time now is 08:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration