So I am trying to set environment variables using my shell Script. The script takes some inputs from the user and then i have to set those inputs in the environment variable. I am using two shell Script for the same but i am getting permission denied errors.
Script 1
DEFAULT_NAME="sample"
read -p "Enter your Name: [$DEFAULT_NAME]: " USER_NAME
if [ -z "$USER_NAME" ]
then
USER_NAME=$DEFAULT_NAME
else
USER_NAME=$USER_NAME
fi
source setEnv.sh
Script 2
echo -e "export NAME=${USER_NAME}" >> /etc/profile.d/nameenv.sh
/etc/profile.d/nameenv.shcan only be written by root.