0

I recently installed a geophysical processing software called Madagascar in Ubuntu 1904. The installation of the program was smooth and I didn't encounter any problems. The problem is that in order to used any program of Madagascar I need to be in Madagascar directory. And before any thing have to type source env.sh to enable environment variables for Madagascar. I have tried to add following line both in .bashrc and .profile but still I need to be Madagascar directory and before anything else need to type source env.sh to run the programs.

shah@vbox:~$ echo 'export PATH=$PATH:/home/shah/madagascar-2.0/env.sh' >> ~/.bashrc

shah@vbox:~$ echo 'export PATH=$PATH:/home/shah/madagascar-2.0/env.sh' >> ~/.profile

shah@vbox:~$ source env.sh 

bash: env.sh: No such file or directory

shah@vbox:~$ sfpen

sfpen: command not found 

shah@vbox:~$ cd madagascar-2.0/ 

shah@vbox:~/madagascar-2.0$ source env.sh

shah@vbox:~/madagascar-2.0$ sfpen

NAME

 sfoglpen

DESCRIPTION

vplot filter for OpenGL.

SYNOPSIS

 sfoglpen colormask= red= green= blue= aspect= ppi= stretchy=n aalias=n   aawidth=1 mono=n endpause= cachepipe= shade= wantras= window= frame= overlay= invras= txsquare= serifs= background= redpow=1.0 greenpow=1.0 bluepow=1.0 dither= greyc=1.0 pixc=1.0 txfont= txprec= txovly= xcenter= ycenter= patternmult=1. pause=0 fatmult= rotate=0 txscale=1.0 mkscale=1.0 dashscale=1.0 scale=1.0 xscale=1.0 yscale=1.0 xshift=0. yshift=0. xwmax= ywmax= xwmin= ywmin= fat=0 bgcolor= erase= break= interact= style= size=

Can someone please help me how to properly add path for this program so that I can use Madagascar from any directory. Regards

Shah5105
  • 57
  • 2
  • 8
  • This just reads like a rant. I assume the question is how to avoid all this faff, but you'll have to take that up with the original developers. Useful software != user-friendly software. – l0b0 Jun 09 '19 at 10:29
  • 1
    You can provide a full path to `source`, like `source ~/madagascar-2.0/env.sh`. Whether it then works depends on details which we can't see. – tripleee Jun 09 '19 at 11:46
  • Thanks a lot @tripleee. You suggestion worked for me. Have a good day – Shah5105 Jun 09 '19 at 11:51
  • I just added `source ~/madagascar-2.0/env.sh` in both `.bashrc` and `.profile`. I don't know what it exactly did but good thing is I can run madagascar commands from any directory. – Shah5105 Jun 09 '19 at 12:00
  • Please read the man page of `bash` to see what `source` is doing. – user1934428 Jun 10 '19 at 07:50

1 Answers1

1

You should take out the changes you made (they are both superfluous and erroneous) and instead simply add

source $HOME/madagascar-2.0/env.sh

to the end of one of your shell's interactive startup files. Which one depends on how exactly your Bash is configured, but if you have a .bash_profile, try that, or else maybe .bashrc.

In some more detail, Bash reads different startup files depending on whether the shell is a login shell and/or an interactive shell. Ideally this should be done in an interactive login shell - login because you only want to do it once (subshells would hopefully inherit these settings) and interactive because you only want and need to run this in an interactive session. But again, what exactly will work will also depend on what exactly env.sh contains.

Your PATH should not contain env.sh because it should contain directories, not file names; and presumably env.sh takes care of actually updating the PATH. Your shell's configuration almost certainly already contains export PATH so there is no need to do that again (multiple times!) either.

tripleee
  • 175,061
  • 34
  • 275
  • 318