Why MATLAB returns -1 when running a script having the function copyfile over SSH
조회 수: 4 (최근 30일)
이전 댓글 표시
It seems like a bug, but whenever you run a MATLAB script over ssh and that script uses the copyfile function, the MATLAB return code is -1 and thus the SSH exit code is 255, This is regardless if the file is copied correctly. Running the same script locally, it works and the return code is 0 as expected.
For reference, copy paste this BASH script. It SSH to localhost, starts MATLAB. Touches a file in /tmp and then copies that file into a new file in /tmp. At the end prints the SSH exit code (spoiler-alert is 255)
#!/bin/bash
HOST=localhost
MATLAB_BIN=/usr/local/MATLAB/R2016b/bin/matlab
MATLAB_SCRIPT="\"
location = '/tmp';
test_file_name = 'matlab-ssh-copyfile-test';
test_file_path = fullfile(location, test_file_name);
new_test_file_path = fullfile(location, 'matlab-ssh-copyfile-new');
fid = fopen(test_file_path, 'w');
fid = fclose(fid);
[b_status, s_message] = copyfile(test_file_path, new_test_file_path);
fprintf(' File copy status %d.\n', b_status);
fprintf(' Exit MATLAB with code 0\n');
exit(0)
\""
ssh -v $HOST $MATLAB_BIN -nosplash -nodisplay -nodesktop -r ${MATLAB_SCRIPT}
exit_code=$?
echo "EXIT CODE ${exit_code}"
댓글 수: 2
Steven Lord
2017년 9월 21일
What is the full text of the error or warning message returned in the s_message output of your call to copyfile?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!