Script ENV issue?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script ENV issue?
# 1  
Old 02-23-2009
Script ENV issue?

Whenever I execute the following korn shell script command I get this error.

su - feeduser

export: =0: not identifier

** Here is the part of the script with the error **

# Set db type (PRODUCTION, DEVELOPMENT, QA, UA)
#
unset DB_TYPE_ERROR
$HOME/share/$DBS_NAME $ORACLE_SID -db_type | read DB_TYPE DB_TYPE_TYPE HOST_TYPE
export ${DB_TYPE}=0

if [ $DB_TYPE_ERROR ];then
echo "ERROR: DB_TYPE=$DB_TYPE_TYPE and HOST_TYPE=$HOST_TYPE don't match"
return 1
fi

Can someone explain to me what this error means and how to correct it?
# 2  
Old 02-23-2009
I have quoted the problem for you:

Quote:
Originally Posted by soupbone38
export ${DB_TYPE}=0
The line has to read]
Code:
export DB_TYPE=0

The reason is: you do not want to use the variable DB_TYPE but you want to declare it. "${var}" means: replace this by whatever content the variable var holds, then execute whatever comes out of this operation. Therefore, when you write

Code:
${DB_TYPE}=0

The shell will first replace the "${DB_TYPE}" with the content of the variable - which is an empty string at this time, because the variable is not declared yet - and therefore end with trying to execute

Code:
=0

Which of course does not make any sense. It is this what the shell complains about.

I hope this helps.

bakunin
# 3  
Old 02-23-2009
Changed the script to reflect recommendation.

# Set db type (PRODUCTION, DEVELOPMENT, QA, UA)
#
unset DB_TYPE_ERROR
$HOME/share/$DBS_NAME $ORACLE_SID -db_type | read DB_TYPE DB_TYPE_TYPE HOST_TYPE
export DB_TYPE=0
if [ $DB_TYPE_ERROR ];then
echo "ERROR: DB_TYPE=$DB_TYPE_TYPE and HOST_TYPE=$HOST_TYPE don't match"
return 1


Now getting error message on this line. on another script

[: !=: missing second argument

here is the second script where the message is coming from.

#
if [ $(echo $DB_TYPE | sed 's/QA/XA/;s/UA/XA/') != $HOST_TYPE ];then
echo "DB_TYPE_ERROR $DB_TYPE $HOST_TYPE"
return 1
fi


Any information?
# 4  
Old 02-24-2009
Quote:
Originally Posted by soupbone38
if [ $(echo $DB_TYPE | sed 's/QA/XA/;s/UA/XA/') != $HOST_TYPE ];then

Any information?
I have singled out the probably erroneous line. Notice that "$var" and "${var}" means basically the same and reread again what i have written before. Price question: what do you think is causing the error?

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: PavanPatil
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. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
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. UNIX for Advanced & Expert Users

problem in Unix Env. in Shell script

sdir;csp os_lib-0.5.24;bdir;cbpdob ---enable-useosstl os_lib-0.5.24;mbp os_lib-0.5.24; If i run this command in unix shell directly it is running. sdir;csp HA_util-0.0.7;bdir;cbpdob ---enable-useosstl HA_util-0.0.7;mbp HA_util-0.0.7; HA_util === Configuring source package HA_util... (4 Replies)
Discussion started by: girija
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. Shell Programming and Scripting

get env variable from last script

I have 2 scripts t2.sh calls t1.sh. I need to get the vaule of a env variable from t1.sh /tmp/test$ cat t1.sh #!/bin/sh INSTANCE="font/fc-cache" export INSTANCE svcadm disable ${INSTANCE} /tmp/test$ cat t2.sh #!/bin/sh . /tmp/test/t1.sh echo ${INSTANCE} The above works... (9 Replies)
Discussion started by: honglus
9 Replies

8. Shell Programming and Scripting

How to execute script one by one in automated env

I have scripts and when I run mannualy it passed but I would like to run one by one at a time like automated. But When I run in one by one in automated the 1st one is executed and did not jump to 2nd one.Please suggest how to run one by one at a time in automated env. sample of Script ... (1 Reply)
Discussion started by: madhusmita
1 Replies

9. Shell Programming and Scripting

Env vars in a SED script

Hello, <Preamble> I'm writing an installation script for use with PKGADD. What I want to do is take one of the variables set in the REQUEST script and use that in the install script so I can change applications configuration. My install script is as follows: sed ' /^DIRNAME/ i\... (8 Replies)
Discussion started by: Bags
8 Replies

10. Shell Programming and Scripting

Adding command line env in cron env

Hello friends, i run two scripts manually & they work. i run them in cron & they don work. how to match the two env's 1.command line env 2.cron env i would like cron to use command line env. Thanks & Regards Abhijeet (1 Reply)
Discussion started by: abhijeetkul
1 Replies
Login or Register to Ask a Question