user1427429 user1427429 - 7 months ago 38
Bash Question

Setting an environment variable in Cygwin

I have been trying to setup a environment variable in Cygwin using the command

export PRIMOSBASE=/directory/for/primosfiles
.

And when i check the variable using the command
echo $PRIMOSBASE
it shows the /directory/for/primosfiles. hopeful this means the environment variable is set.

But when i try to run a shell script(primos) for the /directory/for/primosfiles, it shows

./primos: line 8: /prilaunch.pl: No such file or directory
chmod: failed to get attributes of `step1.sh': No such file or directory


which means i have not set the PRIMOSBASE environment. could anyone please tell me where i am going wrong...

Thanks ...

Answer

Run

echo "export PRIMOSBASE=/directory/for/primosfiles" >> ~/.bashrc

to append the command to the end of your .bashrc file, so that the variable is set each time you use Cygwin. Then run

source ~/.bashrc

to make it take effect immediately.

NOTE: Make sure you use double brackets (>>) to append. It might be a good idea to make a backup of .bashrc just in case. If you're not comfortable with I/O redirection, an alternative is to edit .bashrc with an editor. I think vim is among the default tools in Cygwin.