Page 1 of 1

Spaces in logfile name

Posted: Thu 21 Jul 2016, 11:51
by frankst
Hello,
spaces in the name of a logfile would lead to unexpected results.
The problem is that filenames are not protected by (double-)quotes before using the "system" command.

My (dirty?) solution is to add double-quotes in "RunOpenEMS.m".
See the file excerpt below.
I hope you find this useful.

Cheers
Frank

Excerpt "RunOpenEMS.m":
...
else
args = ["\"" Sim_File "\"" ' ' opts];
if isfield(Settings,'LogFile') && isfield(Settings,'Silent')
invoke_openEMS(args,["\"" Settings.LogFile "\""],Settings.Silent);
elseif isfield(Settings,'LogFile')
invoke_openEMS(args,["\"" Settings.LogFile "\""]);
elseif isfield(Settings,'Silent')
invoke_openEMS(args,[],Settings.Silent);
else
invoke_openEMS(args);
end
end

cd(savePath);
return

Re: Spaces in logfile name

Posted: Thu 21 Jul 2016, 20:29
by thorsten
Using quotes for a command line does not sound like a dirty trick but common sense?
Therefore I think this is a reasonable fix for an otherwise unexpected/broken behavior...

regards
Thorsten

Re: Spaces in logfile name

Posted: Fri 22 Jul 2016, 09:06
by frankst
Hi,
using quotes is of course fine.
But I am not so sure that I added them in the right file.
There might be a better place.
And I did not systematically search for other files that might need editing.
(Actually, this last comment also applies to my Windows powershell edit for the logfile.)

Cheers
Frank

Re: Spaces in logfile name

Posted: Tue 23 May 2017, 10:44
by frankst
To follow up this topic, attached is my edited "RunOpenEMS.m".

Looking at "RunOpenEMS.m" and "RunOpenEMS_MPI.m", there are several other calls of "system" or "unix" commands where I believe they would break if there are spaces in file names or paths. But I cannot test these cases. Thus I do not dare to edit them.

Cheers
Frank