ls command not working properly with Slurm

조회 수: 2 (최근 30일)
EmmaB
EmmaB 2019년 2월 5일
댓글: EmmaB 2019년 2월 6일
Hi,
I'm trying to run a Matlab script with my company's cluster (managed with Slurm). At some point, my script contains a simple
listSuj = ls('Suj*');
command, which works properly when I run the script locally, but does not work as expected when I run it on the cluster. Specifically, on top of returning a list of files or folders whose name begins by 'Suj', it returns the contents of these folders.
I suspect it is due to some interference with the Unix ls command, but I have little to no experience about Unix unfortunately...
Could anyone please let me know how to get Matlab's ls function to run properly?
Thanks!
Emma
  댓글 수: 2
Kojiro Saito
Kojiro Saito 2019년 2월 6일
It might be the current directory of MATLAB from SLURM is not as you expected.
What the
pwd
returns?
And how about adding the following in the first place of MATLAB codes?
cd /path/to/your/directory
EmmaB
EmmaB 2019년 2월 6일
Hi Kojiro,
Thank you for your reply.
I actually cd to the correct directory (with absolute path) just above the ls command, so it's not an issue about the current working directory.
I forgot to mention that I'm a Windows user, if that might be of interest.
Also, the issue is solved when I use
[~, cmdout] = system('ls -d * |grep -i suj');
i.e., it returns a list of the desired folders, but in the form of a character vector, which I then have to sparse into an array of strings, and it is kind of bothersome anyway.
Thanks in advance for your help.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2019년 2월 6일
Using ls to get a list of files or folders is a bad idea in any way. It replies the list a char array, but it is hard to use. So maybe there is another reason to use dir instead:
List = dir('Subj*');
FileName = fullfile({List.folder}, {List.name})
Working with absolute path names is more secure, because the current directory can be changed unexpectedly by callbacks of GUIs or timer 's.
  댓글 수: 1
EmmaB
EmmaB 2019년 2월 6일
Thanks Jan.
Although I thought I had already tried it,
dir('Subj*');
did work!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Third-Party Cluster Configuration에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by