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

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
<package>
        <job id="test">
                <script language="JScript">
                        WScript.stderr.writeLine( "STDERR" );
                        WScript.stdout.writeLine( "STDOUT" );
                </script>
        </job>
</package>
======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

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

--
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/

Reply via email to