Why MATLAB returns -1 when running a script having the function copyfile over SSH
2 次查看(过去 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 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!