Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 Kommentare
Steven Lord
Steven Lord am 21 Sep. 2017
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 am 22 Sep. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by