0

How do I set the environment variables from a script?

Using source scripts/setupenv.sh doesn't seem to work.

I tried to use sh and chmod +x but it still doesn't work.

4
  • In what way does this not work? Does the script contain a shebang? (#!/some/executable at the beginning of the file) – matega Dec 29 '14 at 12:12
  • I just cannot set the environment variables because I don't know which command to use! – N.Der Dec 29 '14 at 12:24
  • 1
    That which you posted is the command to use (source runs the script you specify and retains the variables it sets in your current shell). Where did you get this command and what makes you think it doesn't work? What happens when you run that line? – matega Dec 29 '14 at 12:32
  • Can you edit your question and: 1/ post the contents of the script (precede every line with 4 spaces) and 2/post the output you get from a terminal ([Ctrl][Alt][T]) when you run the script? – Fabby Dec 29 '14 at 13:08
1

It's not very clear what you want to achieve. If you want to set some environment variables for the session, it's worth mentioning that there are existing files for the purpose such as ~/.profile. Please see EnvironmentVariables for more guidance.

3
  • 2
    Great to hear that, @Nora. It would be good if you could let us know how you fixed it, since this is a resource for sharing knowledge and experiences about Ubuntu. – Gunnar Hjalmarsson Dec 29 '14 at 13:37
  • I was typing the command at the wrong folder. – N.Der Dec 30 '14 at 21:24
  • @Nora: Ok. The kind of mistake we all do once in a while. ;) Thanks for clarifying. – Gunnar Hjalmarsson Dec 30 '14 at 23:25

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.