Getting is not an identifier error

Hi all,
I am getting this error while setting CLASSPTH using a script
my script is

#!bin/ksh
export CLASSPATH=$CLASSPATH:<some path>:<some path>

If i do this thing on shell prompt individually it is working fine. but while using in shell script it is giving error.

better if you provide me a sample script which is adding more the 3 path in CLASSPATH

Please its quite urgent

thanks in Advance

regards,
Swat

The following works for me, ie the TEST variable that i export is available within the script whereas not to the shell from which i invoked the script.

#!/bin/ksh
export TEST=$TEST:/home/inangan:/home/inangan/scripts:/home/inangan/tmp
echo $TEST

In case you want these variable to be available for all shell invocation, you may have to add those variables and export them in ~/.profile.

Hope it clarifies,Please let us know if this doesnot solve.

Thanks
Nagarajan Ganesan.

No yaar its still giving problem

You stated :

Note there isn't a " / " before bin. Could this be the problem ? Otherwise the method above is correct. Can you please paste the relevant part of the script ?

testCP.sh: TEST=:/opt/SBM:/opt: is not an identifier
got this error
:mad:

Please post the script which is producing the above error,so that we get an idea on what is happening?

Thanks
Nagarajan Ganesan

#!/bin/ksh
export CLASSPATH=/opt/SBM:/opt:$CLASSPATH

above is script named hi.sh
#sh hi.sh
hi.sh: CLASSPATH=/opt/SBM:/opt:: is not an identifier

now tell me the reason of this error... I am frustated with this error not getting the reason.
one more thing is this when i write export CLASSPATH=/opt/SBM:/opt:$CLASSPATH on the shell prompt it is working fine
now tell me the solution

Can you do the following and post the output ?

set -x
sh hi.sh
set +x

The error is simply because the syntax of:

export CLASSPATH=/opt/SBM:/opt:$CLASSPATH

Is not valid in the bourne shell. In the bourne shell you do the at the same time as the assignment.

Gurus,

In our script we have explicity stated to use ksh as an interprter (#!/bin/ksh) on the first line of script so,

Swat,
Adding to the previous post,

Example in Bourne shell
VAR=/home/user/test:/home/user/test2
export VAR

Should this be working.

Experts please comment.

Thanks
Nagarajan Ganesan

Yes, and it will also wotk in ksh or bash. If you write your code for sh it will work in ksh or bash.

The problem the original poster was seeing was becasue the shell they were using as a login shell supports the short syntax. But they were incorrectly running the script by specifing "sh scriptname", thereby ignoring the #!/bin/ksh in a script that is written as a korn script.

relevant code:
#!/bin/sh

... NOTE: I am accepting parameters passed from Oracle Apps:
relevant code:
var1=$1
var2=$2
var3=$3
ReqID=$4

... NOTE: Displayed parameters are correct when this executes:
relevant code:
echo "$# unnamed params are $@"

... NOTE: I am creating and exporting a new variable using $4:
relevant code:
filename="o$ReqID.out"
export $filename

... NOTE: the error is produced and displays the path and file name of the UNIX script, the correct value for the var, then the error:
...o19130365.out: This is not an identifier.

Can you help?
Thanks!
tg

export the variable not its value.

export filename