Shell Script for Setting Env Variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for Setting Env Variables
# 1  
Old 01-31-2014
Shell Script for Setting Env Variables

Hello All.

Good Afternoon.

I need one small help regarding setting of env variables for a particular host by getting it from the DB.

For ex :

1. I am using LOCALHOST.
2. When I run a ./hostset.sh it should pick up the Oracle home details from associated DB and set it.

Please let me know is it a possible one. I am new this UNIX and I went through some of the links but not quite understanding the concept.

Thank you all for your help in advance.

Regards,
Pavan
# 2  
Old 01-31-2014
Hi, try sourcing the script.
Code:
. ./hostset.sh

Notice the first dot..

That way variables are changed in your current environment. If you execute the script, then it only affects the separate environment that that script runs in.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting ENV variables in PERL

I have perl script and in the first line we are invoking .sh script to set ENV variables. e..g eval '. $envfile; exec $PERL -S $0 "$@"' I want to change some of the env variables while the program is running and I am settging it like this .. $ENV{ORACLE_HOME}=trim($oraclehome);... (1 Reply)
Discussion started by: talashil
1 Replies

2. Shell Programming and Scripting

Env variables in script

Hi All, I have script and it's hardcoded the script ca invoke in user home dir and logs will be redirected to home dir of user. how to make the same script will be invoke from /usr/bin with out chg the logs and other functions path from /user/homedir . code is below: pls check how to... (1 Reply)
Discussion started by: saku
1 Replies

3. Shell Programming and Scripting

tcsh env setting using shell script

Hi All, I have made a file file usercreate.sh & it has to run in tcsh env & needs some path to be set. my script is as below. ########################## #!/bin/csh setenv PATH "/usr/lib/java/class" setenv LD_LIBRARAY_PATH ########################### but when i am ruuning my script... (1 Reply)
Discussion started by: ajaincv
1 Replies

4. Shell Programming and Scripting

Issue with a Unix script Env setting

Hi, I have the below script #------------------------------------------------------------------------------ #Set up environment variables #------------------------------------------------------------------------------ SCRIPTS_DIR=/remedy/scripts/ServerVolumeBilling... (3 Replies)
Discussion started by: anilvaranasi_02
3 Replies

5. Shell Programming and Scripting

Setting Variables WITHIN For Loop in DOS Command Shell

I'm wondering if any of you could lend an assist with a small problem. First, I'm under the impression I need to use Delayed Environment Variable Expansion (DEVE), based on other things I've read across the web. Summary: trying to use command shell (cmd.exe) in XP sp3 (if that's relevant) to... (4 Replies)
Discussion started by: ProGrammar
4 Replies

6. UNIX for Dummies Questions & Answers

Setting env variables using script

Hi, I wrote two small scripts to set env variables in a shell. java_env.csh #!/bin/csh -fn setenv JAVA_HOME '/scratch/software/jdk1.5.0_11' setenv PATH $PATH':'$JAVA_HOME'/bin' and run it using csh ./java_env.csh But the env variables are not set. I tried running each line on the... (5 Replies)
Discussion started by: NoviceAmod
5 Replies

7. UNIX for Advanced & Expert Users

How to export ENV variables, which remains set for all the shell

Hi ! How to export ENV variables, which remains set for all the shell Example :- Login :myID Pwd : **** -> Here my ID .profile is executed. Let say I set MYENV variable Kisses% rlogin ABC -l XXXGroupID -> I login into a remote Solaris Server ABC password : **** -> "XXXGroupID's... (1 Reply)
Discussion started by: dashok.83
1 Replies

8. Programming

including shell env variables into C code

Hey, I'm brushing up on C code and I'm trying to incorporate the shell environmental variables into standard ansi C code. For example I just want to do the equivalent of --echo $PATH-- and implement that in standard ansi C code. How would I do that? Thanks (4 Replies)
Discussion started by: bdsffl
4 Replies

9. Shell Programming and Scripting

Some env setting is causing the script not to work ?

Not sure what has changed in the Unix environment. The following script which was working is now not working. #!/usr/bin/ksh # ----------------------------------------------------------------------------- # File: monitor_db.sh # #... (1 Reply)
Discussion started by: uuser
1 Replies

10. UNIX for Dummies Questions & Answers

Setting up shell variables

Hi everyone, I am trying to set up the .profile for a user I have just created. In trying to set up the shell variables, I want to make the shell be korn shell (default shell i believe is Borne shell), so, this is what I did: SHELL=/usr/bin/ksh export SHELL Whenl executing the .profile,... (1 Reply)
Discussion started by: rachael
1 Replies
Login or Register to Ask a Question