Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

/> 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

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...

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

/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
bananawww.faqs.org/faqs/unix-faq/shell/csh-whynot

![]() |
![]() |
![]() |

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