Capture stdout while waiting for command to finish
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- tuanto@eview-tech.com
- Posts: 3
- Last visit: Thu Apr 28, 2011 4:05 am
Capture stdout while waiting for command to finish
Hello VBscript expert,I am running a Dos command in my vbscript and try to capture all output when the command completes and write to a file. Some times I can capture 1 or 2 lines and miss the rest. Here is a section of my code...Set oFile1 = oFso1.OpenTextFile(LogFile, ForWriting)CommandLine = oArgs(0) & "binEV400hostcmd 86 28." & SNodeSet objWShell = CreateObject("WScript.Shell")Set objWExec = objWShell.Exec(CommandLine)'Capture the output of the command line Do Until objWExec.StdOut.AtEndOfStream strLine = objWExec.StdOut.ReadLine oFile1.WriteLine(strLine) 'WScript.Echo strLine Loop....Can you help?Thanks,Tto
- tuanto@eview-tech.com
- Posts: 3
- Last visit: Thu Apr 28, 2011 4:05 am
Capture stdout while waiting for command to finish
Hello VBscript expert,I am running a Dos command in my vbscript and try to capture all output when the command completes and write to a file. Some times I can capture 1 or 2 lines and miss the rest. Here is a section of my code...Set oFile1 = oFso1.OpenTextFile(LogFile, ForWriting)CommandLine = oArgs(0) & "binEV400hostcmd 86 28." & SNodeSet objWShell = CreateObject("WScript.Shell")Set objWExec = objWShell.Exec(CommandLine)'Capture the output of the command line Do Until objWExec.StdOut.AtEndOfStream strLine = objWExec.StdOut.ReadLine oFile1.WriteLine(strLine) 'WScript.Echo strLine Loop....Can you help?Thanks,Tto
Capture stdout while waiting for command to finish
Please do not post VBSxeipt questions to the command line forum. It is likely that no one will see you request.
You need to wait until the command completes before you try to red the results.
Do While objWExec .Status <> 1 WScript.Sleep 100Loop
See: http://msdn.microsoft.com/en-us/library ... S.85).aspx
jvierra2011-04-28 11:19:52
You need to wait until the command completes before you try to red the results.
Do While objWExec .Status <> 1 WScript.Sleep 100Loop
See: http://msdn.microsoft.com/en-us/library ... S.85).aspx
jvierra2011-04-28 11:19:52