Export environment variable WSL.

조회 수: 11 (최근 30일)
Antoine Legouhy
Antoine Legouhy 2021년 8월 6일
답변: Yongjian Feng 2021년 8월 6일
Hi,
I have Windows Subsystem for Linux (WSL).
In a Matlab script, I want to run some bash commands and scripts, so I do:
system('wsl <script>')
But doesn't work when trying to export an environment variable:
system('wsl export FREESURFER_HOME=\"~/freesurfer\"')
system('wsl echo ${FREESURFER_HOME}')
This returns 0 for both lines (no error) but yet the variable FREESURFER_HOME is not exported.
I also tried to use the setenv command but this adds the variable to the windows environment, not the WSL one:
setenv('FREESURFER_HOME', "~/freesurfer");
system('wsl ${FREESURFER_HOME}') % WSL
% -> *nothing*
system('echo %FREESURFER_HOME%') % Windows
% -> ~/freesurfer\
Any idea on how to export an environment variable in the WSL environment ?
Thanks

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 8월 6일
This is how you set env in wsl:
https://dev.to/kapilgorve/set-environment-variable-in-windows-and-wsl-linux-in-terminal-3mg4

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by