Why MATLAB returns -1 when running a script having the function copyfile over SSH
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Steven Lord
el 21 de Sept. de 2017
What is the full text of the error or warning message returned in the s_message output of your call to copyfile?
Respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!