Setting up a path in UNIX

I have the following script "test". When i tried to execute it, I am not able to run it. I dunno why ? Then i tried getting the first few lines of the script which is displayed below:

$head -10 test
#!/bin/ksh
PROG=$0;export PROG
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`

Now i was asked to set the path for the get_inf_env variable. Could some one help me in letting me know abt how to set up a path ? Any help wud be highly appreciated

Thanks

get_inf_env is not a variable, it is name of some utility being executed. I think your task is to set PATH variable, so get_inf_env can be run in the script without specifying whole path. To do so try:

PATH=/path/containing/get_inf_env:$PATH;export PATH

Add this line as the second line in your script.

1 Like

So do you want me to include the path in the script itself which will probably take the following format

#!/bin/ksh
PROG=$0;export PROG
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`
PATH=/path/containing/get_inf_env:$PATH;export PATH

to set PATH
you have 2 solutions
The 1st is temp

$ PATH=$PATH:/pathto_get_inf_env:/somedir

The 2nd is permanent but it depends on your shell for bash as an example

$ vi ~/.bash_profile

then insert the following line

export PATH=$PATH:/pathto_get_inf_env:/somedir
$ echo 'export PATH=$PATH:/pathto_get_inf_env:/somedir' >> ~/.bashrc

or you can add the absolute path to get_inf_env in your script

Yes, it should be in the script, but not after get_inf_env lines, but before:

#!/bin/ksh
PROG=$0;export PROG
PATH=/path/containing/get_inf_env:$PATH;export PATH
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`

Thanx for all the replies..That was quite informative. Appreciated
But the thing which bothers me is I am not able to find the get_inf_env in the directory.. I have searched in all the directories. But still am not able to find the path for that particular utility..

Did you try this?

find / -name "get_inf_env" -type f

It will take a while to finish but it will find it if it is present on your server.

1 Like

That was awesome..I am able to find the path of "get_inf_env". I am able to find the utility in 2 directories which are mentioned below:

/usr/infa/ie/bin
/usr/infa/dv03/bin

which 1 do i need to consider ?

Well, this question should be directed to someone knowing of the application you are using. I would try setting it to the first directory and see what happens. If the script is not running properly, then set it to the second one :wink: You can also do

ls -l /usr/infa/ie/bin/get_inf_env
ls -l /usr/infa/dv03/bin/get_inf_env

and see if the size is the same, which would suggest that it is the same utility stored in two places and it wouldn't matter which directory you chose.

1 Like

Thanks for that.. it was of the same size. I have included the path in the script.

$ head -10 file
#!/bin/ksh
PROG=$0;export PROG
PATH=/usr/informent/dv03/bin/get_inf_env:$PATH;export PATH
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`

But am not able to run the script..Any help ?

#!/bin/ksh
PROG=$0;export PROG
PATH=/usr/informent/dv03/bin:$PATH;export PATH
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`

Jean-Pierre.

1 Like

Thanks. I am done with that. But when am trying to invoke the script am not able to run the script :wall::wall:

$test
$

What are the possible ways of invoking a script?

Show us more about your script.

Jean-Pierre.

I hope this will suffice. If not I will show the entire script. Thanks

$head -20 test
#!/bin/ksh
PROG=$0;export PROG
PATH=/usr/informent/dv03/bin:$PATH;export PATH
ORAUSER=`get_inf_env INFORM_DB_ACCOUNT`;export ORAUSER
BATCH_HOME=`get_inf_env INFORM_DATA_HOME`

usage()
 {
          echo "                                                                                         "
          echo "__________________________ test_tool_compare_________________________________________    "
          echo "                                                                                         "
          echo "Usage... test_tool_compare (Release 1.0)  June, 2011                        "
          echo "This script generates output to support the parallel test of Partenon generated source    "
          echo " files with Source One generated files.  One test is run per file format.  The Partenon  "
          echo " file is loaded to Informent, saved off to another table, and the SourceOne file         "
          echo " is loaded to Informent and saved to another table.  The data in the 2 saved off tables  "
          echo " are manipulated to create tables, views and reports to assist an analyst with  verifying "
          echo " the parallel data loaded.                                                               "
          echo "                                                                                         "
          echo "The user is prompted to enter File Format, the SourceOne physical file name involved     "
$