
WshShell.Exec what is wrong?
am 01.05.03 00:50 sprach David Ferraro dieses:
Hi David,
Quote:
> I'm building an automated build system using JScript and have run into
> a bit of a problem. The output from my build.cmd is a 300 - 400 lines
> and using WshShell.Exec stops after about 230 lines. I use the
> technique below in several other locations with no problems but when
> the output is large it always fails. Im on XP using version 5.6.
> var shell = new ActiveXObject("WScript.Shell");
> var wsx = shell.Exec("%comspec% /c build.cmd");
Just drop these two lines:
-- >> while((wsx.Status == 0) && (!wsx.StdOut.AtEndOfStream)){
-- >> WScript.Sleep(10);
Quote:
> while(!wsx.StdOut.AtEndOfStream) {
> WScript.Echo(wsx.StdOut.ReadLine());
> }
-- >> }
change it to:
var shell = new ActiveXObject("WScript.Shell");
var wsx = shell.Exec("%comspec% /c build.cmd");
while(!wsx.StdOut.AtEndOfStream) {
WScript.Echo(wsx.StdOut.ReadLine());
Quote:
}
afaik you don't have to check the status-flag here,
because you can access/read the StdOut-TextStream
whether the Exec-Object is terminated or not.
Moreover you dont need to check EOF twice and
you don't need to use "Wscript.Sleep" here, because
"ReadLine" has an implicit Wait-Option.
It waits until it reads an End-Of-Line-Sequence.
If there is none, it'll wait forever.
HTH,
Christoph
Quote:
> I tried ReadAll() but that doesn't produce any output.