register command to run a script file from terminal (how?)

Hello,

I’ve recently installed matlab and after some poking around found that you must start it using a script like:

#>> cd ~root/…/matlab2009/bin/
#>>./matlab

the manual tells me that the installation should have made it so that all you have to do is type matlab at the terminal but for some reason this hasn’t happened. Their website suggests:

If you did not set up symbolic links in the installation procedure, you must enter the full path name to start MATLAB, matlabroot/bin/matlab, where matlabroot is the name of the folder in which you installed MATLAB.

I’ve also looked at documentation on ln but most refers to making links between files.

Is there a way to link the command “matlab” to the file shown above so all I have to do is type the command and it runs the script?

Thanks for your help,

Alex

p.s: Here’s what I’ve tried:

#>> ln -s ~root/…/matlab2009/bin/matlab matlab
linux-2fs6:/home/alex # matlab
If ‘matlab’ is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf matlab

Hi,
Do you know where the matlab executable is located?
You could try “whereis” to find out.
Once you’ve found out (let say it’s /somedir/matlab/matlab) you should
make, for example with Kwrite, a text file containing the following two lines :

#/bin/sh
/somedir/matlab/matlab

(the first line should be exactly as shown, in the second substitute the real filename)
Save that as “matlab” in your ~/bin directory.
Make it executable (for example with dolphin : right click on file-> properties-> access-> check make excutable & apply

Done.

Now typing matlab from a terminal should start your prog.

HTH

Lenwolf

#>> cd ~root/../matlab2009/bin/ 
#>>./matlab
 

This looks as if you think you (or maybe even did) installed that product within the home directory of root. I sincerely hope this is not true. Can you explain how you installed that product?

From the … I think that would be /matlab2009, which isn’t so bad, but not good either. And it’s not good that root is running it. Tsk, tsk.

Uhm,

Yea you guys are right, it’s installed in the OS mount, “/” . Is this bad?

Is “home” a better place for these things (to allow potential future multiple users, unlikely but, just in case)?

Root is running it so I can easily move around the “/” and other directories.

Ok. So saving a script with the command name in the bin folder is how you set a command line, er, command. Thanks! Done indeed!

yay! and even my home user can run it without su-ing!

btw. I love how it actually loads a bunch faster than our school computers, and my computer is by no means fast!

A couple of standard places for third-party software:

/home/something: has the advantage that it stays with /home across upgrades
/opt/something: one of the commonly used places
/usr/local/something: also another commonly used place

In the 2nd and 3rd cases you have to remember that they are usually in the / partition and if you install a new distro release from scratch, you have to take care to carry it over.

It’s bad practice to run things as root unnecessarily. And I will not be the last one to tell you this.

I am afraid you have some misconceptions here. It is not a real problem that it is on the file system that is mounted on /. After all a system can perfectly live with only that one file system. It is that you have it in the home directory of root and that you seem to use root for much to many things. You should only be using the system as root when realy needed: SDB:Login as root - openSUSE.

Now the first thing I would do is trying to undo all you did by “installing” MATLAB. That might be difficult because I guess you did things wrong and did not follow the documentation that came with MATLAB.

Then I would study the documentation that came with MATLAB. Where that is? It depends on how you got MATLAB. You might decide to tell us what you got and might ask for help interpreting the documentation and installing it.

Nah-uh! It’s not in root’s folder!!

I’m just using "~root/… " to refer to “/”

As is now, Matlab can start from a low level user’s prompt after following these instructions.

Seems like the only trouble is that when upgrading the OS I’ll have to be careful to move this folder over… not sure if it’ll have links or something that must be moved too or if it’s all really just self-contained.

I only had root on b/c of instructions that mentioned a sym link and you need root to write to the “/” folder.

Thanks for the info ken_yap, I’ll remember to install to home next time.
Also, thanks lenwolf for the command instructions, worked like a charm!

@Henk: Matlab has a gui installer started from a script, I didn’t notice any extra instructions. Don’t see why they don’t just take care of everything if they’re gonna bother gui-ing it. Didn’t look hard, just dove in, but also never came across instructions dealing with sym-links mentioned in their advice…

Try:


cd
cd bin
ln -s /matlab2009/bin/matlab .

That should put a symlink to matlab in your $HOME/bin directory, which is probably on your path. Depending on your shell, you might need to do “rehash” before it is recognized in the current shell, but it should be immediately available in a new shell (or new terminal window).

On 2011-05-11 22:06, bananapeal wrote:
> I’m just using "~root/… " to refer to “/”
>
> As is now, Matlab can start from a low level user’s prompt after
> following these instructions.
>
> Seems like the only trouble is that when upgrading the OS I’ll have to
> be careful to move this folder over… not sure if it’ll have links or
> something that must be moved too or if it’s all really just
> self-contained.

The place for that kind of software should be /opt/somedirectory. Software
placed on /home/user/somehwere is to be used only by that user. But “/” is
not the place for software, root could be a very small filesystem with no
free space.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

That is a bad invention by yourself. Bad because:
. how could anybody else know what you mean with that invention you kept for yourself?
. ~root/ has a meaning; in the BASH it means: the home directory of root.

Please, when you post computer in/output, do not CHANGE anything. Copy/paste the relevant part of the CLI session (prompts, commands and in/output) to the post and put it between CODE tags (ttp://forums.opensuse.org/english/information-new-users/advanced-how-faq-read-only/451526-posting-code-tags-guide.html). We want to see what happens, not what you think that happens.

Hello all, thanks for the replies.

Regarding location, do you think I can move it to appropriate directory without breaking anything? I have yet to uninstall a program on suse.

Not to beat a dead horse, but is it possible now to take this script in the bin folder (the matlab command itself) and put it in an icon accessible from the desktop, or rather the panel?

I’ve also noticed some discrepancy: I can run it from terminal as normal user but it doesn’t work when using the alt+F2 method of inputting a command. In fact, it starts up then quits during the loading screen. Is there a reason for this?

@Henk: I’ll keep the code tags bit in mind and try to be more careful in the future. didn’t realize

cd /

points to the / directory! (so that’s why the whole ~root business). also I think you still must use

cd ~root/../matlab2009b

in order to make the transition from home to a folder within “/” in one step. (correct?)

I understand that some of these questions aren’t along the lines of “how” but I learn a little bit more from each one. The alt+F2 thing (called kickoff?) seems odd to me and i have no idea how to tell if it’s normal or a bug for instance.

Thanks for your time!

Alex

I do still not understand where you put things. E.g.

cd ~root/../matlab2009b

means that you change directory to
1)* ~root* that is the home directory of user root, which most systems is expanded to /root;
2) that is one directory upwards, thus you are now at /;
3) matlab2009b that is (when it does exist) the directory matlab2009b within where we are, result* /matlab2009*.
When you want to change your working directory to /matlab2009b, it is a way to make difficult what is easy to do with

 cd /matlab2009b

Are you still with me? Sorry for my step by step aproach, but I have the idea that you miss something and I can not lay hand on it.

oh wow.

Ok, I see now. amongst other typos, or perhaps just my misconception, when I saw

cd /matlab 

i thought it referred to cd matlab … but i tried it and it works. Didn’t realize / could be used like that! I thought it was just a space type character to separate folders in a command. For instance in windows i think /directory and directory refer to the same thing…

Thanks for your persistence! I imagine it’s a bit of a bad habit to be doing the ~root when you don’t have to.

The root directory has no name and is written in commands just /
When a path starts with a / it is an absolute path, from the root (/) downwards (or upwards when you like :wink: ).
When a path does not start with a / it is a relative path, that is you start from the working directory where you are.

You should try to forget all those things as they are in MS-DOS. Linux is not Windows.

When I am in my home directory:

henk@boven:~> ls bin
mmcheck
henk@boven:~> ls /bin
arch                  dbus-uuidgen   fsync        loadkeys    nisdomainname  rpm              tar
awk                   dd             fuser        loadunimap  openvt         sash             tcsh
basename              deallocvt      gawk         logger      pgrep          sed              testutf8
bash                  df             getkeycodes  login       pidof          setfont          touch
cat                   dmesg          grep         ls          ping           setkeycodes      true
chgrp                 dnsdomainname  gunzip       lsmod       ping6          setleds          umount
chmod                 domainname     gzip         mail        pkill          setmetamode      uname
chown                 dumpkeys       hostname     mapscrn     ps             setserial        unicode_start
chvt                  echo           initviocons  md5sum      psfaddtable    sh               unicode_stop
cp                    ed             ip           mkdir       psfgettable    showconsolefont  usleep
cpio                  egrep          ipg          mknod       psfstriptable  showkey          vi
csh                   eject          kbd_mode     mktemp      psfxtable      sleep            vim
date                  ex             kbdrate      more        pwd            sort             vim-normal
dbus-cleanup-sockets  false          keyctl       mount       readlink       stat             ypdomainname
dbus-daemon           fgconsole      kill         mountpoint  resizecons     stty             zcat
dbus-monitor          fgrep          ksh          mv          rm             su               zsh
dbus-send             fillup         ln           netstat     rmdir          sync
henk@boven:~>

The outcome is different because they are different places:


henk@boven:~> cd bin
henk@boven:~/bin> pwd
/home/henk/bin
henk@boven:~/bin> cd /bin
henk@boven:/bin> pwd
/bin
henk@boven:/bin>

Please try to read some basic knowledge about Unix/Linux before you start to mess around in your system. Especialy when you are messing around as root!!!

On 2011-05-12 19:06, bananapeal wrote:
> Code:
> --------------------
> cd /matlab
> --------------------
>
>
> i thought it referred to cd matlab … but i tried it and it works.
> Didn’t realize / could be used like that! I thought it was just a space
> type character to separate folders in a command. For instance in windows
> i think /directory and directory refer to the same thing…

In windows, the equivalent is:

Code:

cd \matlab

The inclined line at the start of a name means that it is a directory.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Yeah, well that should be possible.
Here’s how i’d go about it :

Make a new dir somewhere.

Copy all of the content of the old dir accross to the new one (note : copy, not move - don’t delete it in the old dir yet.).

Rename the old dir to something like oldmatlab.
Try typing in “matlab” from the command line.

This SHOULD fail : ItT shows that you renamed your old file OK and thus the command can’t be found yet.

Now, edit the file which you had placed in your /bin directoiry following my earlier advise, and have ot point to the new directory. Save it.

Retry typing in “matlab” from the command line.

If this does work correctly, then it now finds the new dir and everything works correctly from there. For safety, I’d keep the old dir for a few month, checking out whether all features of the program work as expected. If they do, you can delete the old dir at your leisure.

HTH

Lenwolf