Bash Instrcution source dosen't work

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
HeeH

Bash Instrcution source dosen't work

Post by HeeH »

Hello everyone~!

Now I have a urgent porblem: I have tried to install ifort( intel fortran compiler ) on my laptop with mint 14. After the install, I runned the instruction
" source /opt/intel/composer_xe_2013.2.146/bin/compilervars.sh intel64 "
to set the enviroment variables. In the same shell, it worked. But when i quited the shell window and created another shell window to run ifort, the system told me that he can not find instruction ifort.
I have tried to run shell as superuser, but that do not change the enviroment variables either: New window can not run ifort.
I think that is a dirty joker to users and make me a little angry.
Can anyone tell me how to solve that problem? thanks very much!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Bash Instrcution source dosen't work

Post by catweazel »

"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
HeeH

Re: Bash Instrcution source dosen't work

Post by HeeH »

I doubt that it is not the problem of Intel: The ifort ran well but i can not modify the enviroment variables. Is there anyway that I can run "source" in shell truely as superuser?
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Bash Instrcution source dosen't work

Post by karlchen »

Hello, HeeH.
After the install, I runned the instruction
" source /opt/intel/composer_xe_2013.2.146/bin/compilervars.sh intel64 "
to set the enviroment variables. In the same shell, it worked. But when i quited the shell window and created another shell window to run ifort, the system told me that he can not find instruction ifort.
This suggests that you will have to put the commandline

Code: Select all

 source /opt/intel/composer_xe_2013.2.146/bin/compilervars.sh intel64 
into your personal .bashrc file.

Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Bash Instrcution source dosen't work

Post by bjornmu »

Environment variables are not "global", they only have effect within the shell that you set them. So it's as expected that they don't work when you open another shell. But if you put this in your .bashrc as suggested, it will be run whenever you start a new shell.
HeeH

Re: Bash Instrcution source dosen't work

Post by HeeH »

karlchen wrote:Hello, HeeH.
After the install, I runned the instruction
" source /opt/intel/composer_xe_2013.2.146/bin/compilervars.sh intel64 "
to set the enviroment variables. In the same shell, it worked. But when i quited the shell window and created another shell window to run ifort, the system told me that he can not find instruction ifort.
This suggests that you will have to put the commandline

Code: Select all

 source /opt/intel/composer_xe_2013.2.146/bin/compilervars.sh intel64 
into your personal .bashrc file.

Karl
Thanks very much! It works! Now I am compiling my project of fortran for my course. Thank you for your help!
HeeH

Re: Bash Instrcution source dosen't work

Post by HeeH »

bjornmu wrote:Environment variables are not "global", they only have effect within the shell that you set them. So it's as expected that they don't work when you open another shell. But if you put this in your .bashrc as suggested, it will be run whenever you start a new shell.
Thanks very much! Now I begin to understand how the Linux deals with environment variables: it is different from the windows. Thank you for your help!
User avatar
karlchen
Level 23
Level 23
Posts: 18177
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Bash Instrcution source dosen't work

Post by karlchen »

Hello, HeeH.
You're welcome. :)
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
cfaj

Re: Bash Instrcution source dosen't work

Post by cfaj »

bjornmu wrote:Environment variables are not "global", they only have effect within the shell that you set them. So it's as expected that they don't work when you open another shell. But if you put this in your .bashrc as suggested, it will be run whenever you start a new shell.
Environment variables, i.e. those that are exported, are available to all descendants shells.

Note that the source command is specific to bash, and not available in sh (which is dash on Debian-based systems); use '. scriptname' instead.
Locked

Return to “Scripts & Bash”