Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

every body I am new in centos server I am getting a error while using 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)

Now i am confuse after lot of searching. So please some one help get rid of this error

share|improve this question

migrated from serverfault.com Jul 31 '13 at 20:06

This question came from our site for system and network administrators.

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.