LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 05-22-2013, 11:51 AM   #1
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
unable to set env variables in a script


Hello,

I am struggling with this script which I have to create to startup app database at reboot. Now the problem is before running the command to start the database I am suppose to set some environment variable for the system.

This is the file which contains all the env variable and manually I run using this command
Code:
# . tux.env
Code:
# less tux.env
TUXDIR=/u01/Tuxedo/tuxedo10gR3; export TUXDIR
JAVA_HOME=/u01/peoplesoft/jre; export JAVA_HOME
JVMLIBS=$JAVA_HOME/lib/amd64/server:$JAVA_HOME/jre/bin
PATH=$TUXDIR/bin:$JAVA_HOME/bin:$PATH; export PATH
COBCPY=:$TUXDIR/cobinclude; export COBCPY
COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"; export COBOPT
SHLIB_PATH=$TUXDIR/lib:$JVMLIBS:$SHLIB_PATH; export SHLIB_PATH
LIBPATH=$TUXDIR/lib:$JVMLIBS:$LIBPATH; export LIBPATH
LD_LIBRARY_PATH=$TUXDIR/lib:$JVMLIBS:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
WEBJAVADIR=$TUXDIR/udataobj/webgui/java; export WEBJAVADIR
and after this the startup command
Code:
# psadmin -p start  -d fin91dmo
But If I want to automate my work adding this in a script as shown below
Code:
# less app.sh
#!/bin/bash

TUX_DIR="/u01/Tuxedo/tuxedo10gR3"
cd $TUX_DIR
. tux.env

PS_HOME=/u01/peoplesoft
sh $PS_HOME/psconfig.sh

psadmin -p start  -d fin91dmo
psadmin -c boot -d fin91dmo
Now every time I run this script it says
Code:
psadmin command not found
which means path variable are not getting set I believe.
Am I doing any thing wrong as I am not so good with scripts.
Is there any way I can automate this process?
 
Old 05-22-2013, 12:29 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
try
Code:
/path/to/psadmin -p start  -d fin91dmo
/path/to/psadmin -c boot -d fin91dmo
in the script.
 
1 members found this post helpful.
Old 05-22-2013, 12:32 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
or try set -xv at the beginning of the script (as second line)
 
1 members found this post helpful.
Old 05-22-2013, 03:01 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Do what Habitual says about paths to executables, always code with the known path name.

Notice how you defined TUX_DIR within your script, that's also something you can do.

However if you run the tux.env and export variables you should be able to import those variables in your script using "import VAR"
 
1 members found this post helpful.
Old 05-22-2013, 06:09 PM   #5
jatal
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
another option :: alter path

Another option would be to alter the PATH defined in tux.env to ensure the psadmin executable is on the path.

If you find that is not working, echo $PATH before the command is executed to make sure the path is set as you expect. It is possible another script alters the path.
 
1 members found this post helpful.
Old 05-23-2013, 02:15 AM   #6
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195

Original Poster
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by Habitual View Post
try
Code:
/path/to/psadmin -p start  -d fin91dmo
/path/to/psadmin -c boot -d fin91dmo
in the script.
Hello I thought of using this but the thing is that particular command requires other env variables to be set as well.

So I decided to put the path of those variables in my .bash_profile and it is working.
Now when I start my machine the database gets up without any problem but the problem starts when we login to that user using putty or and client software the .bash_profile script runs again leading to run those commands for starting database

Well I knew about this consequence before using .bash_profile for setting up environment variable.

I tried to manually assign those variables in my script but I do not understand why it does not works.

Code:
# vi app.sh
#!/bin/bash

TUXDIR=/u01/Tuxedo/tuxedo10gR3
export TUXDIR
JAVA_HOME=/u01/peoplesoft/jre
export JAVA_HOME

PS_HOME=/u01/peoplesoft
sh $PS_HOME/psconfig.sh

psadmin -p start  -d fin91dmo
psadmin -c boot -d fin91dmo
Quote:
Originally Posted by pan64 View Post
or try set -xv at the beginning of the script (as second line)
Can you please show me an example using my script as I had used "set" without any switches and it was not working
 
1 members found this post helpful.
Old 05-23-2013, 02:42 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
you can use this way:
Code:
#!/bin/bash
set -xv

TUXDIR=.....
or
bash -xv <your script>

this will produce an output about the running script and you will see what was happening.
 
  


Reply



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
Can't set root env variables in script? voyciz Slackware 3 09-23-2009 07:44 PM
how to set env variables for oracle 10g xe ?? y2raza Linux - Newbie 11 03-05-2008 10:13 AM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
how do you set an env variable from within a csh script? BrianK Linux - General 3 05-26-2004 02:16 PM
where are the env variables set on boot? Pete Dogg Linux - Software 1 09-10-2003 02:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:41 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
Open Source Consulting | Domain Registration