Prev: Binary to fixed point, HELP !!!!!
Next: Help needed: VideoCompressor property of video.MultimediaFileWriter
From: Roy on 2 Aug 2010 09:08 I'm using 2010a on an Intel Mac. Previously, I had trouble getting Matlab to find things in my Unix Path, which I figured out how to fix when I started this thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/255609 I'm not actually doing that anymore. Instead, I have the following lines in my startup.m file: %%%%%% BEGIN MATLAB SNIPPET %%%%%%%%%% % Add additional directories to the path path1 = getenv('PATH'); path1 = [path1 ':/usr/local/bin:/usr/texbin:/usr/X11/bin:/sw/bin:/Users/roy/bin']; setenv('PATH', path1); clear path1; %%%%%% END MATLAB SNIPPET %%%%%%%%%% This has worked fine for me, and is mostly sufficient Now, I also have a .bash_profile file in my home directory with a lot of aliases that I'd like to be able access from my m-files. From the command line, I have typed "!source ~/.bash_profile" but my aliases are still unavailable. For example, I have the line alias email='open -a Mail.app' in the .bash_profile file, which allows me to email files from the current directory by typing "email foo.jpg" for example. However, entering >> !email foo.jpg at the Matlab command line gives /bin/bash: email: command not found /bin/bash: email: command not found
From: Walter Roberson on 2 Aug 2010 11:27 Roy wrote: > From the > command line, I have typed "!source ~/.bash_profile" but my aliases are > still unavailable. That sources your bash profile into the shell that ! starts up. That shell is then closed as soon as the source command is finished, losing the aliases. A shell started through ! or unix() or system() would not be marked as an interactive or login shell at invocation, and so would not normally process .bashrc . Perhaps you could use BASH_ENV http://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files
From: Roy on 3 Aug 2010 11:26 I tried to implement your suggestion by adding this line to the end of my startup.m file: setenv('BASH_ENV','.bash_profile'); I also chmodded my .bash_profile to make it executable, because the link you sent made it look to me that this would be necessary. I still get the same error message.
From: Walter Roberson on 3 Aug 2010 11:54 Roy wrote: > I tried to implement your suggestion by adding this line to the end of > my startup.m file: > > setenv('BASH_ENV','.bash_profile'); > > I also chmodded my .bash_profile to make it executable, because the link > you sent made it look to me that this would be necessary. > I still get the same error message. I suggest trying system('echo $SHELL') to double-check that bash is indeed the shell that is used by system(). Usually system() uses sh, which on your system might or might not be the same as bash.
From: Roy on 3 Aug 2010 12:33
> I suggest trying > > system('echo $SHELL') > > to double-check that bash is indeed the shell that is used by system(). > Usually system() uses sh, which on your system might or might not be the > same as bash. It's bash alright: >> system('echo $SHELL'); /bin/bash |