Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Thu, 29 Jan 2004 09:09:22 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Clint Bennion cc: cygwin AT cygwin DOT com Subject: Re: stderr issues when running bat scripts In-Reply-To: <20040129065003.26042.qmail@web13901.mail.yahoo.com> Message-ID: References: <20040129065003 DOT 26042 DOT qmail AT web13901 DOT mail DOT yahoo DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Note-from-DJ: This may be spam 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 > > OS > 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 . 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 > > > > > > ======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. > > Clint Did you try the latest snapshot? There were some problems with 1.5.6 that were fixed in CVS. See . Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,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 Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/