0

I don't know if I worded the question correctly, because I'm quite new to shell programming (If that's how it's called).

#!/bin/bash
cd /Applications/MATLAB_R2016b.app/bin
./matlab -nosplash -nodisplay -nodesktop 

system('sleep 20')
cd /Users/WillyGuerrero/Documents/MATLAB/Examples/BodePlotOfDynamicSystemExample/
BodePlotOfDynamicSystemExample
system('sleep 20')
exit;
exit 0

Thats my entire shell script. First three lines, I open MATLAB in Terminal, once the instance is open I wait (without success) 20 seconds, i then move to the folder containing my ML script, open it, so some processing, hence the 20 seconds wait, exit the ML instance and then close the terminal Window.

Tha thing is my shell script won't run anything once the ML instance is open, and I'm out of ideas.

I tried googling my problem, but I'm pretty sure I can't get the wording right, therefore I ask you guys for help.

Thank you in advance.

P.S

I know the commands are not that wrong since I can open a Terminal window and write them by hand and the thing will run.

  • Thank you @that other guy, but I'm still quite lost. Could you help me? – Memo Guerrero Jul 02 '18 at 03:59
  • [This answer](https://stackoverflow.com/a/37586820/1899640) has a part that starts "which also conveniently allows you to use here documents:". You can copy that, replace `ssh user@remote` with `./matlab -nosplash -nodisplay -nodesktop ` and `uname -a` with `system('sleep 20')`. If you find it easier, you can also put your matlab commands in a separate script called `mymatlabscript` and run `matlab < mymatlabscript` – that other guy Jul 02 '18 at 04:49
  • You're awesome mate. I'm not that much of an experienced programmer and folks like you are life savers! Thanks! – Memo Guerrero Jul 02 '18 at 05:18
  • Okay, I'm still a failure in coding bash scripts. Wanna help more? – Memo Guerrero Jul 02 '18 at 13:31
  • You can run it through [ShellCheck](https://ShellCheck.net) to autodetect common issues, and it'll probably be easier to post a new question so you'll have space to include your (hopefully minimal but tested) code, expected result and actual result – that other guy Jul 02 '18 at 16:37

0 Answers0