diff --git a/matlab/RunOpenEMS.m b/matlab/RunOpenEMS.m index 4151007..0e2140a 100644 --- a/matlab/RunOpenEMS.m +++ b/matlab/RunOpenEMS.m @@ -13,6 +13,8 @@ function RunOpenEMS(Sim_Path, Sim_File, opts, Settings) % Settings.SSH.host = '' % Settings.SSH.bin = '/openEMS.sh' % +% Settings.LogFile = 'openEMS.log' +% % RunOpenEMS(Sim_Path,Sim_File,opts,Settings) % % See also WriteOpenEMS @@ -50,7 +52,12 @@ if (isfield(Settings,'SSH') && isunix) error('openEMS:RunOpenEMS','scp failed!'); end - status = unix(['ssh ' Settings.SSH.host ' "cd /tmp/' ssh_work_path ' && ' Settings.SSH.bin ' ' Sim_File ' ' opts '"']) + if isfield(Settings,'LogFile') + append_unix = [' 2>&1 | tee ' Settings.LogFile]; + else + append_unix = []; + end + status = unix(['ssh ' Settings.SSH.host ' "cd /tmp/' ssh_work_path ' && ' Settings.SSH.bin ' ' Sim_File ' ' opts '"' append_unix]) if (status~=0) disp(result); error('openEMS:RunOpenEMS','ssh openEMS failed!'); @@ -71,7 +78,11 @@ if (isfield(Settings,'SSH') && isunix) end else args = [Sim_File ' ' opts]; - invoke_openEMS(args); + if isfield(Settings,'LogFile') + invoke_openEMS(args,Settings.LogFile); + else + invoke_openEMS(args); + end end cd(savePath); diff --git a/matlab/invoke_openEMS.m b/matlab/invoke_openEMS.m index 4079878..5672d20 100644 --- a/matlab/invoke_openEMS.m +++ b/matlab/invoke_openEMS.m @@ -1,4 +1,4 @@ -function invoke_openEMS( opts ) +function invoke_openEMS( opts , logfile) % function invoke_openEMS( opts ) % % internal method to invoke openEMS, use RunOpenEMS instead @@ -30,5 +30,10 @@ else end command = [openEMS_Path ' ' opts]; + +if (isunix && nargin>1) + command = [command ' 2>&1 | tee ' logfile]; +end + disp( ['invoking openEMS simulator: ' command] ); system(command);