nohup matlab - how to pass input to scripts

I'm trying to run scripts on a remote server by using the following command, where TEST(.m) is my script.
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; TEST; catch; save code_err; end; quit' > output.log
I want to run functions as well, for instance a function TEST(argin1,argin2), but the following command doesn't work:
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; TEST(argin1,argin2); catch; save code_err; end; quit' > output.log
What should be the correct syntax?
EDIT: What is the syntax to launch functions that require inputs?

4 Kommentare

Rik
Rik am 3 Mär. 2021
With this syntax you can only run scripts or functions that do not require any input.
That means you will have to define your input arguments in your initial call, or call a script that will set the values of the inputs.
Andrea Togni
Andrea Togni am 3 Mär. 2021
Hi Rik.
Thank you for your comment. Do you happen to know a different syntax to launch functions that require inputs?
That would really solve my issue!
Rik
Rik am 3 Mär. 2021
You will need to define the variables. Where are the values for argin1 and argin2?
Andrea Togni
Andrea Togni am 3 Mär. 2021
In my case, they will be the directories of the datasets I work on.
I want to input them each time differently and avoid saving them in .txt files to avoid confusion when editing and launching.
E.g. TEST('/home/folder/subfolder/dataset1','/home/folder/subfolder/dataset2')

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 3 Mär. 2021

0 Stimmen

So actually your question is how to define a char array inside such a call. I suspect you simply need to escape the quotes:
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; TEST(''/home/folder/subfolder/dataset1'',''/home/folder/subfolder/dataset2''); catch; save code_err; end; quit' > output.log

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 3 Mär. 2021

Beantwortet:

Rik
am 3 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by