8

I have a command such as "C:\Program Files\7-zip\7z.exe" x foo.7z -y which will extract (with full paths) to the current directory.

What it does that I don't want, though, is to spool out the individual paths to stdout. This is information that I don't need.

However, on Windows, redirecting this to NUL (the equivalent of /dev/null on Linux) a la "C:\Program Files\7-zip\7z.exe" x foo.7z -y > NUL produces no unzip'd files, because 7-Zip seems to unzip to NUL instead of pushing the command text-output to NUL (which is what we want).

Actually, that command works from a Windows command shell (that is, it unzips the files as I want but without logging text to the console), but ir doesn't from TeamCity's agent execution within its command-line build-runner (that is, it unzips into NUL).

How do I get it to do the same thing within TeamCity (which is executing as a service)?

0

2 Answers 2

8

Try doing this:

%COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ...
3
  • Thanks; that worked (although I don't really know why). May 11, 2011 at 22:46
  • @Peter: TeamCity is likely actually executing it with the argv [... "-y", ">", "NUL"] or otherwise executing the file "C:\Program Files\7-Zip\7z.exe x foo.7z...".
    – Hello71
    May 12, 2011 at 0:02
  • Ah, yes; that would make sense. It has one textbox to take the exe, and one to take the arguments. May 12, 2011 at 0:08
2

7z.exe x foo.7z -y > NUL Works fine in my case. Are you sure the behavior is not caused by something else and you do not see the error message because of output redirection?

Also, you can redirect the output into a file instead of NUL and thus also exclude it from the output.

1
  • 1
    It works fine for me from a console too; it doesn't work fine when it's the TeamCity build-agent (running as a service) that is executing the command headlessly. It's the TeamCity involvement that made this a stackoverflow.com question, which was why I asked there; unfortunately it got moved and I don't know how to appeal to a moderator. May 11, 2011 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .