matlab & linux: pipe openEMS output to log file
parent
936983c331
commit
eea46a922d
|
@ -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];
|
||||
if isfield(Settings,'LogFile')
|
||||
invoke_openEMS(args,Settings.LogFile);
|
||||
else
|
||||
invoke_openEMS(args);
|
||||
end
|
||||
end
|
||||
|
||||
cd(savePath);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue