14

When I am using the following command

         setenv CLASSPATH /path/mysql-connector-java-ver-bin.jar:$CLASSPATH

error is

        bash setenv command is not found

When i find path of setenv by which command , then i found following path

 (/usr/kerberos/sbin:/usr/kerberos/bin:/home/ec2/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ec2/bin:/root/bin)
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

2 Answers2

19

setenv belongs to (t)csh, not to bash which is the default shell in CentOS. Use

export CLASSPATH="/path/mysql-connector-java-ver-bin.jar:$CLASSPATH"

instead.

3

Even better because more clean, use prefix notation (without set) on the command you want to invoke:

CLASSPATH=/path/mysql-connector-java-ver-bin.jar:$CLASSPATH ANOTHER_VAR=bla ATHIRD_VAR=blu java -...

Now the java process you invoke will be able to gather your temporary environment variable(s) CLASSPATH, ANOTHER_VAR and ATHIRD_VAR.

If you used export, then the variables will also be set globally(?), at least on the script's environment. And, values of variables which already existed would be overwritten by the new values.

Advantages of prefix notation:

  • previous values of a variable should stay unchanged, i.e. in the case the old values are being needed later on, then there would be no need to save the old values of the variables which already existed in order to restore them after the invocation
  • no need to unset your temporary variables for cleanup purposes after the invocation