Page 1 of 2 12 LastLast
Results 1 to 10 of 17

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

  1. #1

    Question 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

  2. #2

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

    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

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,163

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

    [
    Code:
    #>> 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?
    Henk van Velden

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

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

    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.

  5. #5

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

    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!

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

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

    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.

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,163

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

    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.
    Henk van Velden

  8. #8

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

    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...

  9. #9
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,641
    Blog Entries
    3

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

    Try:
    Code:
    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).
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  10. #10
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

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

    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)

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •