Why MATLAB returns -1 when running a script having the function copyfile over SSH

4 ビュー (過去 30 日間)
NIKOLAOS BOURAS
NIKOLAOS BOURAS 2017 年 9 月 21 日
編集済み: NIKOLAOS BOURAS 2017 年 9 月 22 日
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
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?
NIKOLAOS BOURAS
NIKOLAOS BOURAS 2017 年 9 月 22 日
There is no error message. The copyfile works as intended ( It copies the file and b_status == 1) however after this the MATLAB exit code is -1.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by