Problem with redirecting output

Mar 21, 2011
30
0
Output redirections from piped command don't seem to work. While in CMD the follwing works fine, but in TCC/LE it just hangs:

Code:
@echo off
REM Check Windows Version
ver | findstr /i "5\.0\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto :warn_and_exit
What can I do about this?

Thanks.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,856
48
Albuquerque, NM
prospero.unm.edu
Output redirections from piped command don't seem to work. While in CMD the follwing works fine, but in TCC/LE it just hangs:

Code:
@echo off
REM Check Windows Version
ver | findstr /i "5\.0\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_2000
ver | findstr /i "5\.1\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_XP
ver | findstr /i "5\.2\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_2003
ver | findstr /i "6\.0\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_Vista
ver | findstr /i "6\.1\." >nul
IF %ERRORLEVEL% EQU 0 goto ver_Win7
goto :warn_and_exit
What can I do about this?

Thanks.
It works here. By "works" I mean that it doesn't hang, it displays an error message about a missing label, which is reasonable because the label doesn't exist.

(This seems like an awfully cumbersome way to test versions, by the way. It would be a whole lot simpler to check the value returned by %_WINVER.)
 
Mar 21, 2011
30
0
You might post the contents of your TCSTART.BTM file, if you have one. Possibly it's doing something in the pipe shell which the redirection prevents you from seeing.
Yes, I have a TCSTART.CMD and quite a lot of customisations in TCMD.INI, and I tried removing them, to eliminate the problem, after seeing that the script worked fine on another machine.

It turns out that the same TCC/LE directory installation will work on any other machine (same OS), but not this one.

I cannot figure out what is causing this, but at least this is not a permanent problem. Thanks for your help.
 
FWIW I have had the following lines of code at the start of my 4START/TCSTART/4EXIT/TCEXIT, dating back many years (April 2000), to mitigate issues with piping:

Code:
REM Check to see if we're running in a transient shell or a pipe
IFF %_TRANSIENT == 1 .OR. %_PIPE == 1 THEN
  ECHO %@NAME[%_BATCHNAME] - processing short-circuited for transient shell
  QUIT
ENDIFF
Obviously the ECHO is unnecessary, but it can help with debugging.