Killrazor
Killrazor

Reputation: 7176

Lua and the white spaces in an OS

After reading this post, I used [[ ]] to put commands into the system. The problem is the following: The same structure:

local Program = [["c:\Archivos de programa\Automated QA\TestComplete 8\Bin\TestComplete.exe" ]];
local testcase = [["C:\svn_test\trunk\Automation\XMM\XMM.pjs" ]];
local options = [[/r /exit /p:XMMGeneralTest /t:"Script|main|Main" ]];

local cmd = Program..testcase..options;
print(cmd);
os.execute(cmd);

local tcLog = [[ C:\svn_test\trunk\Automation\XTYLE\XTyleGeneralTest\Log\11_04_2011_12_40_06_264\*]];
local zippedFile = "11_04_2011_12_40_06_264.7z ";
local sevenZip = [["c:\Archivos de Programa\7-Zip\7z.exe" a -t7z ]];

local cmd = sevenZip..zippedFile..tcLog;
print(cmd);
os.execute(cmd);

The same code produce different results. The first one doesn't run:

"c:\Archivos" not recognized as internal command or external,
program...

The second one runs perfectly.

How can I resolve this?

Upvotes: 0

Views: 967

Answers (1)

BMitch
BMitch

Reputation: 263519

I also don't have a windows system to test with, so this is just a guess:

Try replacing this:

local Program = [["c:\Archivos de programa\Automated QA\TestComplete 8\Bin\TestComplete.exe" ]];

with this:

local Program = [[c:\\Archivos\ de\ programa\\Automated\ QA\\TestComplete\ 8\\Bin\\TestComplete.exe ]];

I fear that it won't work since the [[ and ]] will block the interpretation of the escapes, but that may change as it goes from one variable to another and then to the os.execute. The other option is to use the windows version of these files without spaces, e.g.:

local Program = [[c:\Archiv~1\Automa~1\TestCo~1\Bin\TestComplete.exe ]];

Upvotes: 1

Related Questions