Run matlab script on remote windows computer using cmd

Hello,
I am trying to run several different MATLAB scripts on a remote windows computer to aggregate data from various sensors. How can I start a matlab script from cmd over ssh? I have tried matlab -nodesktop -noFigureWindows -nosplash -r "myscript; exit", but the script never runs.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 8 Aug. 2025

1 Stimme

I suspect that there is a conflict between the "-nodesktop" optoin and the "-r statement".
Try matlab -nodesktop -noFigureWindows -nosplash -batch "myscript"
From the document
-batch statement
Execute MATLAB script, statement, or function non-interactively. MATLAB:
  • Starts without the desktop
  • Exits automatically with exit code 0 if statement executes successfully. Otherwise, MATLAB terminates with a non-zero exit code.
-r statement
Execute the MATLAB statement. Use this option for interactive workflows. Do not use this option with the -batch option.

4 Kommentare

Thanks. This worked great, replacing -r with -batch.
I retract my previous statement. This doesnt work all the time. I run into a license issue if I ssh into the remote windows computer on startup and run a script. I can get the script to work if I remote desktop into the remote computer and open MATLAB first. This sequence allows me to run a command via ssh. Do you know how to fix this?
Need clarification.
1. Connect through a remote desktop APP
Run matlab -nodesktop -batch "myscript". Successful!
2. Connect through SSH
Run matlab -nodesktop -batch "myscript". License error!
What is the error message? What is the pwd() when you run "matlab" (are they different in the above two cases?). How is MATLAB license specified?
For license issue, you could specify a license file directly when calling "matlab", e.g.
matlab -c "c:\MathworksLicense\NetworkLicense.lic"

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Gefragt:

am 7 Aug. 2025

Kommentiert:

am 25 Aug. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by