Why doesn't getenv work on MAC OS X?
조회 수: 15 (최근 30일)
이전 댓글 표시
I was trying to get environment variables that I know exist but it returns empty arrays...is that normal?
hello =
00 empty char array
res =
00 empty char array
>>
from running
hello = getenv('hello')
res = getenv('SYSTEMROOT')
----
These are the scripts I am exactly running:
#!/bin/bash
alias matlab='/Applications/MATLAB_R2017a.app/bin/matlab -nodesktop -nosplash'
hello=hellohello
echo $hello
matlab -nodesktop -nosplash -nojvm -r "test_sh"
which runs the following:
clear;
%SLURM_JOBID = getenv('SLURM_JOBID')
%SLURM_ARRAY_TASK_ID = getenv('SLURM_ARRAY_TASK_ID')
hello = getenv('hello')
res = getenv('SYSTEMROOT')
PATH = getenv('PATH')
댓글 수: 2
Jos (10584)
2017년 12월 11일
How do you know they exist? Apparently Matlab cannot find them. I have no problem on my Mac.
답변 (1개)
Greg
2017년 12월 12일
One article I read indicates you need to call
export hello
To actually set hello as an environment variable. Otherwise, hello only exists as a "shell variable." I'm definitely not a MAC wizard, so I have no clue if that's correct, just a quick Google search.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Cluster Configuration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!