Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

How to set environment variable

Original Message
Name: chain
Date: October 14, 2003 at 03:30:18 Pacific
Subject: How to set environment variable
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.


Report Offensive Message For Removal


Response Number 1
Name: Miskva
Date: October 14, 2003 at 07:40:08 Pacific
Subject: How to set environment variable
Reply: (edit)
/> 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



Report Offensive Follow Up For Removal

Response Number 2
Name: WilliamRobertson
Date: October 14, 2003 at 10:51:20 Pacific
Subject: How to set environment variable
Reply: (edit)
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...



Report Offensive Follow Up For Removal

Response Number 3
Name: Miskva
Date: October 15, 2003 at 06:24:16 Pacific
Subject: How to set environment variable
Reply: (edit)
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



Report Offensive Follow Up For Removal

Response Number 4
Name: WilliamRobertson
Date: October 15, 2003 at 15:53:19 Pacific
Subject: How to set environment variable
Reply: (edit)
/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



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: How to set environment variable

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC