matlab & linux: pipe openEMS output to log file

This commit is contained in:
Thorsten Liebig 2010-06-21 12:17:19 +02:00
parent 936983c331
commit eea46a922d
2 changed files with 19 additions and 3 deletions

View File

@ -13,6 +13,8 @@ function RunOpenEMS(Sim_Path, Sim_File, opts, Settings)
% Settings.SSH.host = '<hostname or ip>' % Settings.SSH.host = '<hostname or ip>'
% Settings.SSH.bin = '<path_to_openEMS>/openEMS.sh' % Settings.SSH.bin = '<path_to_openEMS>/openEMS.sh'
% %
% Settings.LogFile = 'openEMS.log'
%
% RunOpenEMS(Sim_Path,Sim_File,opts,Settings) % RunOpenEMS(Sim_Path,Sim_File,opts,Settings)
% %
% See also WriteOpenEMS % See also WriteOpenEMS
@ -50,7 +52,12 @@ if (isfield(Settings,'SSH') && isunix)
error('openEMS:RunOpenEMS','scp failed!'); error('openEMS:RunOpenEMS','scp failed!');
end 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) if (status~=0)
disp(result); disp(result);
error('openEMS:RunOpenEMS','ssh openEMS failed!'); error('openEMS:RunOpenEMS','ssh openEMS failed!');
@ -71,7 +78,11 @@ if (isfield(Settings,'SSH') && isunix)
end end
else else
args = [Sim_File ' ' opts]; args = [Sim_File ' ' opts];
invoke_openEMS(args); if isfield(Settings,'LogFile')
invoke_openEMS(args,Settings.LogFile);
else
invoke_openEMS(args);
end
end end
cd(savePath); cd(savePath);

View File

@ -1,4 +1,4 @@
function invoke_openEMS( opts ) function invoke_openEMS( opts , logfile)
% function invoke_openEMS( opts ) % function invoke_openEMS( opts )
% %
% internal method to invoke openEMS, use RunOpenEMS instead % internal method to invoke openEMS, use RunOpenEMS instead
@ -30,5 +30,10 @@ else
end end
command = [openEMS_Path ' ' opts]; command = [openEMS_Path ' ' opts];
if (isunix && nargin>1)
command = [command ' 2>&1 | tee ' logfile];
end
disp( ['invoking openEMS simulator: ' command] ); disp( ['invoking openEMS simulator: ' command] );
system(command); system(command);