WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: alruma on July 25, 2014, 03:34:47 AM

Title: pipe does not work
Post by: alruma on July 25, 2014, 03:34:47 AM
Hello,
i would like to pipe the screen-output from a WinZip-view into a file with that command:
unZipres = RunWait("C:\Program Files\Winzip\WZUNZIP.EXE",  "-v C:\MOB_PROG\Tools\CUDB_Export\Tests\UnZip\PROD_EXPORT_20140603_0850.ZIP >C:\MOB_PROG\Tools\CUDB_Export\Tests\UnZip\ZipRes2.txt")

But it does not work with RunWait nor RunShell.
i am using 2014A.
The same Unzip-command works well in a DOS-Batch

Regards
Ruedi
Title: Re: pipe does not work
Post by: snowsnowsnow on July 25, 2014, 04:56:41 AM
Terminology nitpick: it is called "redirection", not "piping".  Piping is something else.

Substantive answer: The redirection is performed by the shell, not by the command itself, so you have to invoke the shell in order for redirection to be recognized and acted upon.

So, the usual WinBatch idiom for running shell command lines is like this:

RunWait(Environment("COMSPEC"),StrCat("/c ",yourUsualShellCommandHere))

Note that you might also want to look at the recent thread about redirecting the output of DOS commands "into WinBatch".