matlab & linux: pipe openEMS output to log file

pull/1/head
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.bin = '<path_to_openEMS>/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);

View File

@ -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);