Created
June 17, 2014 09:24
-
-
Save amodig/c09a7b33f42a51b8ec9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
logpath='./log/batcher.log' | |
# remove old output | |
#rm ${logpath} | |
matlab_exec='sudo -H -u amodig /usr/local/MATLAB/R2012a/bin/matlab' | |
r_exec='sudo -H -u amodig /usr/bin/Rscript' | |
# first argument for MATLAB (function) | |
cmdMATLAB="${1}" | |
# second argument for R (script) | |
cmdR="${2}" | |
# Note: will concatenate log file | |
echo '--------------------------------NEW BATCHER------------------------------' >> ${logpath} | |
date >> ${logpath} | |
# execute MATLAB script | |
echo 'Running MATLAB command:' | |
echo ${cmdMATLAB} > matlab_command.m | |
cat matlab_command.m | |
# stdout and stderr to stdout and append to log | |
(${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command.m 2>&1) | tee -a ${logpath} | |
# execute R script | |
echo 'Running Rscript:' | |
echo ${cmdR} | |
(${r_exec} ${cmdR} 2>&1) | tee -a ${logpath} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment