How to set environment variable
I am relitively new to linux and just download a program. It ask me to set the environment variable VAR to the name of a directory.
I tried both in command line: "export VAR=/home/dir/" but the system just say: "export: Command not found." How can I set an environment variable? Thanks |
The method you used should have worked. Just to be sure, I just tried it, and it worked for me. You must be typing into a bash shell, because it's bash that you're asking to export this variable with its value. You should also be able to pass VAR to the program, call it "prog", this way: "VAR=/home/dir/ prog".
|
export command is built into bash and ksh. If you are using another shell (e.g. csh or tcsh) it might not be. Variable assignments in other shells are done differently. For example in the original Bourne shell (sh) you had to do two steps:
VAR=value export VAR (or VAR=value;export VAR - the semicolon makes it execute the second part of the line after the first part as if you had typed two lines.) Type "ps" without any options - this should show you what shell you are running. If it shows "sh" instead of bash or ksh then type "which sh" - this will show you where it found the "sh" command (e.g. /bin/sh). Type "ls -l <path-to-shell>" where path to shell is what you found in the prior step. Look to see if /bin/sh is a link (will show a right arrow pointing to another file) to something else. Someone recently posted that they were linked to tcsh. |
You use "setenv VARIABLE value" in C shell.
|
You could just assign the environmental variable in your ~/.profile script. Here is an example from mine:
Code:
# Most applications support several languages for their output. |
I find out I am in C shell,
and tried:"setenv VARIABLE value" It worked Thanks a lot |
You can also know which shell you are running by typing
echo $0 There is a key combination that displays the bash version but I can't remember it. If somebody knows it, just shout. |
http://en.wikipedia.org/wiki/Command_line_completion ...try here for the CLI steps to resolve the scripts/line resolve for YOUR files. Good luck to YOU.
|
All times are GMT -5. The time now is 12:44 PM. |