Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12285
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | Re: using wshell.exec causes lockup while reading the output - what to do ? |
| Date | 2020-06-18 19:42 +0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <e9938l04vk2i.1v164vs1agbr2.dlg@40tude.net> (permalink) |
| References | <rcd2h8$trv$1@gioia.aioe.org> <sb6rcvp4ls4f$.epdabohe21mk$.dlg@40tude.net> <rcdhn1$thu$1@gioia.aioe.org> |
On Wed, 17 Jun 2020 18:51:41 +0200, R.Wieser wrote:
>
> That should not be a problem. As long as the program that is exec-ed runs
> it should be generating output (in a seperate thread I presume), and the
> buffer should eventually gain some new contents. But no, I can see the
> output stops somewhere rather early, nowhere near to the end.
It doesn't matter whether the program output/error is written by multithread
or not, because the problem lies within the TextStream object's methods.
> Regardless, do you have any suggestions to how to solve it/what to try ?
When the input is a character device, instead of a file, don't use counted
read operation unless you know exactly when the program stops writing data
into a standard handle. That would produce a deadlock unless the program
generate at least the same length of data being requested to read.
In your code, you have these lines:
if not oExec.stdout.atendofstream then wscript.echo oExec.stdout.read(1000)
if not oExec.stderr.atendofstream then wscript.echo oExec.stderr.read(1000)
If the program writes some lines totalling 500 bytes into standard output,
the script will be stuck within `oExec.stdout.read(1000)` because it's
expecting 500 more bytes of data.
It'be better to read the program output line by line like below.
do while not oExec.stdout.atendofstream
wscript.echo oExec.stdout.readline
loop
> Or should I conclude that trying to grab output from an "exec" method is
> undependable, and thus simply a waste of time ?
What's wrong with that? I use it myself to parse various programs' output,
as well as input commands into the executed programs.
Back to microsoft.public.scripting.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-17 14:32 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? "Mayayana" <mayayana@invalid.nospam> - 2020-06-17 08:48 -0400
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-17 22:12 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-17 18:51 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-18 19:42 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-18 17:26 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-19 21:16 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-19 19:08 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-20 22:40 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-20 18:56 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-21 12:33 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-21 08:53 +0200
Re: using wshell.exec causes lockup while reading the output - what to do ? JJ <jj4public@vfemail.net> - 2020-06-21 20:58 +0700
Re: using wshell.exec causes lockup while reading the output - what to do ? "R.Wieser" <address@not.available> - 2020-06-21 17:46 +0200
csiph-web