1

I am new on Ubuntu and Linux, shell scripting etc. I have prepared a small script in order to set some enviromental variables, in order to make my life faster and work more efficient with a program. While it is easy to open the terminal and set the that manually.

if [ -f /home/lefteris/uems/etc/EMS.profile ]; then
  . /home/lefteris/uems/etc/EMS.profile
fi

When I put it on a script, which I call variables.sh it is not working. File it is like that.

#!/bin/bash

if [ -f /home/lefteris/uems/etc/EMS.profile ]; then
  . /home/lefteris/uems/etc/EMS.profile
fi

Please, tell me what I am doing wrong.

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39

1 Answers1

0

You can't set environment variables just by running the shell script. You have to source it or use dot space script method.

You have used a correct method above, but when putting it in a script file and executing doesn't set the variables as you again trying to set variables by running the script.

You can try . variables.sh or source variables.sh

Refer this question for more details.

sumedhe
  • 934
  • 1
  • 13
  • 30