Spaces in logfile name

Give some feedback on openEMS.

Moderators: thorsten, sebastian

Post Reply
frankst
Posts: 32
Joined: Thu 21 Jul 2016, 11:36

Spaces in logfile name

Post by frankst » Thu 21 Jul 2016, 11:51

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

thorsten
Posts: 1388
Joined: Mon 27 Jun 2011, 12:26

Re: Spaces in logfile name

Post by thorsten » Thu 21 Jul 2016, 20:29

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

frankst
Posts: 32
Joined: Thu 21 Jul 2016, 11:36

Re: Spaces in logfile name

Post by frankst » Fri 22 Jul 2016, 09:06

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

frankst
Posts: 32
Joined: Thu 21 Jul 2016, 11:36

Re: Spaces in logfile name

Post by frankst » Tue 23 May 2017, 10:44

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
Attachments
RunOpenEMS.m
Prevent some failures if spaces are used in log files or sim files.
(6.57 KiB) Downloaded 237 times

Post Reply