I am having problems with simple scripting, my Box is CentOS so bash is the default shell, now I wanted to send a line via setenv (tcsh) and would like to make a script that will ask me to input a string to setenv every time I login.

By the way I am using teraterm logging in.


setenv belongs to (t)csh, not to bash which is the default shell in CentOS. Use export instead. Ref : bash setenv command is not found

Then considering you would input MY_VARIABLE=MYVALUE

echo -n "Enter the env string"
read env
echo export "$env" >> $HOME/.bash_profile
. $HOME/.bash_profile

Edit : I have modified my code as the previous one would not really export env to all bash shell considering. This one will but the variable in the bash_profile file which is executed each time a bash is opened.

  • Consider revising my post, I modified the code for a more efficient one. – Jean-François Savard May 30 '14 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.