Computing.Net > Forums > Unix > How to set environment variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to set environment variable

Reply to Message Icon

Name: chain
Date: October 14, 2003 at 03:30:18 Pacific
OS: sun5.8
CPU/Ram: 512
Comment:

Hi,
I was wondering how to set enviroment variable in CSH script ? Reason because I set crontab to run a csh script that contains this command:

sqlplus -s dummy/dummy @/dir/path/temp.tmp > /log/path/cmp3.log

And it does not run that statement at all, eventhough when I run the statement manually it runs fine. Pls advice. Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: Miskva
Date: October 14, 2003 at 07:40:08 Pacific
Reply:

/> variable_name=value

and if you need the variable outside of the script, add :

/> export variable_name

Also check AT is actually picking it up

Miskva



0

Response Number 2
Name: WilliamRobertson
Date: October 14, 2003 at 10:51:20 Pacific
Reply:

Typically the problem in cron jobs is that the cron process won't automatically load all the environment variables you take for granted in an interactive session such as $ORACLE_SID, $ORACLE_HOME, $PATH containing $ORACLE_HOME/bin, $LD_LIBRARY_PATH, maybe $CLASSPATH etc. If you write (or already have) a settings script you'll need to call it from the script you run in cron, e.g:

. /some/explicit/path/oracle_envs

btw I think in csh you set environment variables with something weird like

set variablename = value
(for a local variable)

or

setenv variablename = value
(for an exported variable)

Does it have to be csh? Kind of makes everything harder...



0

Response Number 3
Name: Miskva
Date: October 15, 2003 at 06:24:16 Pacific
Reply:

Seems like these are two different issues here:

1. how to set variables in your shell; this may depend on the type of shell, my examples are for ksh, I can only guess they will work in other shells (shells shouldnt be that different)

2. using variables: its like you say, create a new script, which first initiates its variables, then perform the other scripts (which will be using these variables) If this script works from command line, it should work from cron as well

. set_something
some_script.sh
other_script.sh



0

Response Number 4
Name: WilliamRobertson
Date: October 15, 2003 at 15:53:19 Pacific
Reply:

/Users/williamr: csh

williamr% var1=banana
var1=banana: Command not found.

williamr% export var1
export: Command not found.

williamr% set var1 = banana

williamr% print $var1
print: Command not found.

williamr% echo $var1
banana

www.faqs.org/faqs/unix-faq/shell/csh-whynot



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: How to set environment variable

How to set a variable www.computing.net/answers/unix/how-to-set-a-variable/4718.html

How to set up SMTP www.computing.net/answers/unix/how-to-set-up-smtp/4700.html

how to set up default printer www.computing.net/answers/unix/how-to-set-up-default-printer-/4637.html