Remote matlab running: changing folder and running script

4 次查看(过去 30 天)
I was wondering how to change a matlab directory while using ssh in puTTY for a remote session that does not end when I close the ssh terminal.
So far I have:
nohup matlab -nodesktop -nodisplay < sshTest.m &
I have also tried:
nohup matlab -nodesktop -nodisplay < cd(DIRECTORY) sshTest.m &
But I get the following error:
-bash: syntax error near unexpected token `('
My matlab directory is different than the initial directory when I ssh. I am comfortable completing this in several lines, however I am unsure how to include 'nohup' for continued running of the script even if I lose connection to the server within the several line method.
This is how I did it in multiple lines:
matlab -nodesktop -nodisplay
cd(DIRECTORY)
sshTest
Any help is appreciated. Thank you.

采纳的回答

Steven Lord
Steven Lord 2022-9-1
Instead of piping the contents of the file to MATLAB, use the -batch or -r startup options in conjunction with the -sd startup option.
  1 个评论
AES
AES 2022-9-1
@Steven Lord Do you have resources for using the -sd in the startup file?
I have been trying this:
-sd 'DIRECTORY'
But I get this error and the start directory is not changed:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should
be resolved as soon as possible. Error detected was:
MATLAB:m_missing_variable_or_function
Error: File: /(startup location)/startup.m Line: 30 Column: 5
Invalid use of operator.
It said the error was in the line that I included the above -sd...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by