- NSIS Discussion
- Devilishly cunning new problem re nsExec::Exec
Archive: Devilishly cunning new problem re nsExec::Exec
RobGrant
5th October 2004 10:19 UTC
Devilishly cunning new problem re nsExec::Exec
OK, I _had_ it working where I unzipped a zip file and captured the output of the unzip program so I could log the files extracted like so:
!macro MACRONAME UNZIP FILE PATH
ExpandEnvStrings $0 "%COMSPEC%"
nsExec::Exec '"$0" /C ${UNZIP} ${PATH} -o ${FILE} >> "$INSTDIR\filelist.log"'
!macroend
I'd call it with:
!insertmacro MACRONAME "C:\temp\unzip.exe" "warfile.war" "-dwardirectory"
All fine. The moment I try and change the directory the unzip program is in however:
!insertmacro MACRONAME "$INSTDIR\temp\unzip.exe" "warfile.war" "-dwardirectory"
And it does absolutely nothin. Doesn't unzip, certainly doesn't log anything. Any ideas? I don't really know what info to give...I'm on Windows XP, NSIS version 2.01
Cheers guys
Rob
RobGrant
5th October 2004 10:42 UTC
I should add - it unzips fine if I remove the command line append, ie:
nsExec::Exec '$0 /C ${UNZIP} ${PATH} -o ${FILE}'
Yathosho
5th October 2004 10:50 UTC
you might probably prefer the ExtractDLL over using an external program. should also solve your problem.
RobGrant
5th October 2004 10:57 UTC
Ooh interesting! Quick q rather than me having to hunt around the docs - where do i unzip it to?
RobGrant
5th October 2004 11:28 UTC
Having looked, I assume I put ExtractDLL.dll in the plugins dir, and the rest in a folder called ...\Contrib\ExtractDLL. So I do this:
Push "$INSTDIR\dir\webapp.war"
Push "$INSTDIR\dir\webapp\"
CallInstDLL ExtractDLL extract
This just creates a file called "webapp" which is precisely 0 bytes big. Any chance of it extracting to a directory?
Cheers
Rob
RobGrant
5th October 2004 15:03 UTC
Bump!
I really don't see what's wrong here. If I even log the thing i'm chucking into nsExec and then paste the log line into a command prompt it works beautifully:
C:\WINDOWS\system32\cmd.exe /C "C:\Program Files\C-Evolution\robtest\temp\unzip.exe" -dcevolution-client -o cevolution-client.war >> "C:\Program Files\C-Evolution\robtest\filelist.log"
But nsExec just hates it with a passion.
RobGrant
5th October 2004 15:25 UTC
I think I've narrowed it down. It doesn't like it when unzip.exe's path has a space in it (e.g. Program Files).
Not sure whether this is a problem with cmd.exe or nsExec, anyone know?
Afrow UK
5th October 2004 18:58 UTC
You might need more quotes around your strings:
nsExec::Exec '$0 /C "${UNZIP}" "${PATH}" -o "${FILE}"'
Like you have said, if the path contains a space, it will become two arguments rather than the one, and so you should use quotes to declare it as one.
Oh and if I were you, I wouldn't use ExtractDLL. While I was using it to uncompress around 200 Zip's (for updating games) ExtractDLL wouldn't decompress about 25% of the Zip's and Unzip / WinZip would, thus now I use unzip.exe.
-Stu
RobGrant
6th October 2004 09:02 UTC
Yeah I agree ExtractDLL seems slightly suspect in terms of it doing what I'd expect it to do each time.
However I am trying all combinations of quoting and not quoting, and I'm not sure what the difference is. The behaviour changes ONLY when I use the append output '>>' operator, as thought as soon as I use that then spaces in paths become a problem.
Also extracting out the sample you give would make for an unusual command:
"C:\Program Files\unzip.exe" "-ddirectory" -o "file.war"
Like, some unzip.exe arguments quoted and some not? And would I quote the bits after the '>>'?
RobGrant
6th October 2004 09:03 UTC
As I said, if I LogText the exact input I give to nsExec, and then paste that logged text into a command line, it works perfectly from the command line.
Here's the line:
C:\WINDOWS\system32\cmd.exe /C "C:\Program Files\C-Evolution\robtest\temp\unzip.exe" -dcevolution-client -o cevolution-client.war >> "C:\Program Files\C-Evolution\robtest\filelist.log"
kichik
10th October 2004 14:49 UTC
cmd.exe and command.com might also expect 8.3 file names. Paths with spaces might not be valid. I'm pretty sure it doesn't work with command.com.