permanently adding specific variable to the PATH variable

Asked by bhaskar

I am using Ubuntu 11.04 Natty Narwal and recently i tried to install MATLAB 2010a and the result is that i am unable open the installed matlab.
And i found that if i add /usr/local/matlab2010a/bin/ to the existing PATH variable then my shell is recognising the matlab as a shell command and executing the matlab. And after immediate closing of Terminal my added path variable is missing from the original PATH variable.
The procedure i followed for adding matlab path variable is shown below:
PATH=$PATH:/usr/local/matlab2010a/bin/
export PATH

PATH variable before adding matlab: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PATH variable after adding matlab: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/matlab2010a/bin/

Now one more problem is that i am unable to add matlab under desktop shortcut because i don't want to run matlab from terminal every time.

My system architecture details from command uname -a are shown below:
Linux bhaskar-Inspiron-1525 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686 i686 i386 GNU/Linux

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :
#1

there are two ways to do this.

PATH=$PATH:/new/path matlab

would work.

Also, modifying your .bash_profile to add

PATH=$PATH:/new/path
export $PATH

and then in gnome-terminal, ensure you check the box that says "login shell" in the preferences menu (edit->profile preferences->edit->title and command->run command as login shell)

Also, you may want to (for future reference only), be aware of the scilab package. As this is free software it is maintained to work out-of-the-box.

Revision history for this message
bhaskar (hinduvsp) said :
#2

Sorry mycae, the process mentioned above is not holding my new PATH variable and i am requesting some more solution.

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#3

if you add it in ~/.bashrc it will apply it. You can add:

export PATH=$PATH:/usr/local/matlab2010a/bin/

Should be ok

Revision history for this message
bhaskar (hinduvsp) said :
#4

Thanks actionparsnip, now the shell holding my matlab PATH variable into the existing PATH variable.Can you help me to create a desktop shortcut for this matlab application in order access matlab from desktop.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

Right click desktop and click to make a new launcher. Then navigate to the binary you want to run.

Revision history for this message
bhaskar (hinduvsp) said :
#6

When i try the procedure you mentioned and i am getting the following error from the desktop shortcut:

There was an error launching the application.
Details: Failed to execute child process "matlab" (No such file or directory)

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#7

Can you give the output of:

ls -la /usr/local/matlab2010a/bin/

Thanks

Revision history for this message
bhaskar (hinduvsp) said :
#8

bhaskar@bhaskar-Inspiron-1525:~$ ls -la /usr/local/matlab2010a/bin/
total 608
drwxr-xr-x 7 root root 4096 2011-08-20 02:38 .
drwxr-xr-x 16 root root 4096 2011-08-20 02:38 ..
-r-xr-xr-x 1 root root 21615 2010-01-04 18:11 activate_matlab.sh
-r-xr-xr-x 1 root root 20450 2010-01-04 18:11 deactivate_matlab.sh
-r-xr-xr-x 1 root root 18652 2009-12-11 15:23 deploytool
-r-xr-xr-x 1 root root 10418 2010-01-04 18:09 engopts.sh
-r-xr-xr-x 1 root root 12101 2010-01-04 18:09 gccopts.sh
drwxr-xr-x 7 root root 36864 2011-08-20 02:37 glnx86
-r--r--r-- 1 root root 19 2009-05-15 16:32 insttype.ini
-r--r--r-- 1 root root 109093 2009-05-15 16:32 lcdata.xml
-r-xr-xr-x 1 root root 1541 2009-05-15 16:32 lcdata.xsd
-r-xr-xr-x 1 root root 12651 2010-01-04 18:09 ldd
-r--r--r-- 1 root root 1640 2009-11-13 03:35 license.txt
drwxr-xr-x 2 root root 4096 2011-08-20 02:35 m3iregistry
-r-xr-xr-x 1 root root 54915 2010-01-04 18:09 matlab
-rwxr-xr-x 1 root root 12869 2011-08-20 02:38 .matlab7rc.sh
-r-xr-xr-x 1 root root 10417 2010-01-04 18:09 matopts.sh
-r-xr-xr-x 1 root root 81107 2010-01-04 18:09 mbuild
-r-xr-xr-x 1 root root 10829 2010-01-04 18:09 mbuildopts.sh
-r-xr-xr-x 1 root root 43736 2010-01-04 18:09 mcc
-r-xr-xr-x 1 root root 47744 2010-01-04 18:09 mex
-r-xr-xr-x 1 root root 10594 2010-01-04 18:09 mexext
-r-xr-xr-x 1 root root 12979 2010-01-04 18:09 mexopts.sh
-r-xr-xr-x 1 root root 758 2009-05-15 16:32 mw_mpiexec
-r-xr-xr-x 1 root root 567 2009-05-15 16:32 mw_smpd
-r-xr-xr-x 1 root root 7217 2010-01-04 18:09 optsetup.sh
-r-xr-xr-x 1 root root 212 2009-05-15 16:32 ProductRoots
drwxr-xr-x 2 root root 4096 2011-08-20 02:35 registry
drwxr-xr-x 2 root root 4096 2011-08-20 02:29 scripts
drwxr-xr-x 3 root root 4096 2011-08-20 02:29 util
-r-xr-xr-x 1 root root 531 2009-05-15 16:32 worker

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#9

Then make the launcher point to:

/usr/local/matlab2010a/bin/matlab

Should be ok

Revision history for this message
bhaskar (hinduvsp) said :
#10

Hi actionparsnip,
Now the matlab opening from the launcher but after 2 sec it closes automatically that mean the matlab dialogue box opening but closing immediately.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#11

I'm not that conversant with Matlab, if you find out what binary you need to run then you can set that up, you may need to run the start matlab command before running it, you'll find out with websearches

Revision history for this message
bhaskar (hinduvsp) said :
#12

Thanks actionparsnip,
You did the right job but in the launcher it needs extra desktop word and i found from the ubuntuforums.org.
The same weblink is posting here in order to help for others:
http://ubuntuforums.org/showthread.php?t=1460710

The necessary launcher command is /usr/local/matlab2010a/bin/matlab -desktop
Now my matlab works great and i will be thankful for your continuous help.

Revision history for this message
bhaskar (hinduvsp) said :
#13

Thanks actionparsnip, that solved my question.