vist64 / wintee

Automatically exported from code.google.com/p/wintee
0 stars 0 forks source link

When using ERRORLEVEL / EXITSTATUS, I only get a 0 from wtee instead of my command #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Is there a workaround for this in windows/command prompt? 

What is the expected output? What do you see instead?

I would like to see the errorlevel of the command instead of always getting a 0 
for wtee successfully writing output to my log file

What version of the product are you using? On what operating system?

Windows 2003 Server, Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by dcman...@gmail.com on 28 Jun 2010 at 9:14

GoogleCodeExporter commented 8 years ago
First of all, gnu tee also has the same behaviour and since the wtee is 
analogue of tee this is not an real issue for wtee. Moreover, I've been 
struggling with the same problem you described and finally found out that it is 
the pipe which is responsible on windows platform which prevents from passing 
exit status. There, actually, workaround solutions with reading exit status 
before piping and saving it for further utilization. Anyway, this is not a tee 
who responsible for inability to pass pass exit status. If you have different 
opinion, please let me know. 
Pavel

Original comment by pmodilay...@gmail.com on 12 Dec 2010 at 8:47

GoogleCodeExporter commented 8 years ago
Could you please pass more information about the issue with windows ?
Any idea how we could workaround it ? 
Even on the WinApi level.

Thanks!

Original comment by pavel.savara on 8 Nov 2011 at 3:23

GoogleCodeExporter commented 8 years ago
Gnu tee does also have the same issue, but there are workarounds on *nix (see 
http://lists.samba.org/archive/linux/2004-March/010158.html and its links). 
Unfortunately, there don't seem to be documented workarounds for use on 
windows. I am using GnuWin32's tee 
(http://gnuwin32.sourceforge.net/packages/coreutils.htm and elsewhere) and had 
to quit because I need to check the return code of the command I am teeing. So 
how can we use tee on windows and still check return codes?

Original comment by pckuj...@gmail.com on 6 Jun 2012 at 7:58

GoogleCodeExporter commented 8 years ago
In case someone still stumbles over this:
I had the same issue and tried several tee for Windows and workarounds.
Only solution I found is to run the command in powershell. There you have a tee 
and errorlevel/exit code is retained. Can also be passed to the batch file from 
which you called it from (if you leave the rest in a batch file).

Example powershell script:
<mycommand> 2>&1 | tee logs/mylogfilename_$(get-date -f dd.MM.yyyy_HH-mm-ss).log
exit $LastExitCode

Original comment by harald.g...@gmail.com on 16 Apr 2014 at 2:09