Guest User

Untitled

a guest
Jun 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2. #Launch matlab and run a single command, returning an exit code of 1 if there's an error.
  3. #
  4. #For example, if you had a matlab command:
  5. #mungeData('infile.mat', 'outfile.mat')
  6. #
  7. #then with this script you can do
  8. #./runmatlab mungeData('infile.mat', 'outfile.mat')
  9. #
  10. #from the shell, or a makefile.
  11. #
  12. #Peter Meilstrup
  13.  
  14. status=`mktemp -t matlab.status`
  15. #escape single quotes
  16. args=${@//\'/\'\'}
  17.  
  18. $(which matlab) -nodesktop -nosplash -maci <<EOF
  19. try
  20.     cd('$(pwd)');
  21.     eval('${args}');
  22. catch e
  23.     system('echo 1 > $status');
  24.     fprintf(2,'%s',evalc('disp e'));
  25.     exit();
  26. end
  27. system('echo 0 > $status');
  28. exit();
  29. EOF
  30.  
  31. exit `cat $status`
Add Comment
Please, Sign In to add comment