This is the mail archive of the
mailing list for the Cygwin project.
Re: stderr issues when running bat scripts
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Clint Bennion <cd_bennion at yahoo dot com>
- Cc: cygwin at cygwin dot com
- Date: Thu, 29 Jan 2004 09:09:22 -0500 (EST)
- Subject: Re: stderr issues when running bat scripts
- References: <firstname.lastname@example.org>
- Reply-to: cygwin at cygwin dot com
On Wed, 28 Jan 2004, Clint Bennion wrote:
> Although this appears on the surface to be a windows issue I am bringing
> this to the cygwin group for two reasons.
> 1 - It only fails when I run it from a bash shell.
> 2 - It recently started failing. I re-installed an older version of the
> cygwin package and the problem goes away.
> Version that failed:
> Cygwin 1.5.6-1
> Tested working version:
> Cygwin 1.5.5-1
> Windows 2000 Professional
> 5.0.2195 Service Pack 4 Build 2195
There's more to your Cygwin configuration than the version of the DLL.
Please read and follow <http://cygwin.com/problems.html>. Attaching the
output of "cygcheck -svr" is not optional.
> Here are two scripts for a test case. The bat script calls the cscript in a for loop. The for
> loop catches the last line from stdout and puts it in the variable out. The cscript simply puts
> the text "STDOUT" to stdout and "STDERR" to stderr.
> ======Start tst.bat
> rem echo "" 1>&2
> echo "********************************"
> set CMD=cscript /nologo tst.wsf
> FOR /F "delims=#" %%A IN ('%CMD%') DO set OUT=%%A
> echo %OUT%
> ======End tst.bat
> ======Start tst.wsf
> <job id="test">
> <script language="JScript">
> WScript.stderr.writeLine( "STDERR" );
> WScript.stdout.writeLine( "STDOUT" );
> ======End tst.wsf
> ======Start output
> m:\class\cmd>rem echo "" 1>&2
> m:\class\cmd>echo "********************************"
> m:\class\cmd>set CMD=cscript /nologo tst.wsf
> m:\class\cmd>FOR /F "delims=#" %A IN ('cscript /nologo tst.wsf') DO set OUT=%A
> m:\class\cmd>set OUT=CScript Error: Execution of the Windows Script Host failed.
> (Unspecified error
> m:\class\cmd>set OUT=)
> m:\class\cmd>echo )
> =========End Output
> There are multiple things that I can do to get the scripts to run.
> 1) Uncomment the first echo line. This line redirects a return to stderr.
> 2) Don't ever send to stderr in the cscript
> 3) Redirect either stdout or stderr to a file when running tst.bat
> Another interesting test case that I will describe. Adding a line with
> "%CMD%" before and after the for loop causes the cscript to be called
> directly. In this case the first call succeeds. The for loop fails and
> the next call to cscript fails.
> I probably shouldn't do this, since I know so little about the inner
> workings, but here is my musings. It would seem that the for loop causes
> special problems. Possibly because it is doing a form of redirection,
> stdout to the set commands and stderr should go to the screen.
> Although this causes problems for future calls to cscript I don't know
> why. It must be that adding the echo to stderr at the first causes the
> plumbing for stderr to be setup properly and all future commands
> succeed. There is no need to respond to this paragraph. I wrote it
> just to help get the thought process going if it is needed.
Did you try the latest snapshot? There were some problems with 1.5.6 that
were fixed in CVS. See <http://cygwin.com/snapshots/>.
|\ _,,,---,,_ email@example.com
ZZZzz /,`.-'`' -. ;-;;,_ firstname.lastname@example.org
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html