[vwnc] ExternalProcess

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] ExternalProcess

Facundo Ciccioli
Hello. I'm willing to use class ExternalProcess because I need to run
some script files (.bat) on a server through a web interface. The
script does a synchronization with another server so it takes a while
to finish. It would be nice if I could access the "output until now"
of the script, instead of having to wait until it finishes to see the
entire output at once. Is this possible? I saw that the
ExternalProcess readStream's is protected by a mutex, so I figure it's
not possible to access it while the script is being executed, but I'm
really not sure about this.

My OS is Windows XP and I'm using VisualWorks 7.6.

Thanks a lot in advance,
FaQ
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] ExternalProcess

Michael Lucas-Smith-2
Hi Facundo,

Yes you can do it - you're probably using the shOne: command on
ExternalProcess. If you dip in to its messages, you'll see that it
eventually called fork:arguments: which hides the streaming from you.
Try this:

ExternalProcess
    execute: myCommand
    arguments: myArrayOfArguments
    do: [:in :out | [in atEnd] whileFalse: [Transcript show: in nextLine]]
    errorStreamDo: [:error | error upToEnd]

The stderr and stdin streams must both be read, since you do not know
what the program you're running is going to output to. Be aware of how
your program intends to write to the output - if it always writes out
full lines, then the above program will work well - if it doesn't, you
may end up waiting for a character that will never come (that's also
okay so long as the program you're running quits when it's done).

Cheers,
Michael

Facundo Ciccioli wrote:

> Hello. I'm willing to use class ExternalProcess because I need to run
> some script files (.bat) on a server through a web interface. The
> script does a synchronization with another server so it takes a while
> to finish. It would be nice if I could access the "output until now"
> of the script, instead of having to wait until it finishes to see the
> entire output at once. Is this possible? I saw that the
> ExternalProcess readStream's is protected by a mutex, so I figure it's
> not possible to access it while the script is being executed, but I'm
> really not sure about this.
>
> My OS is Windows XP and I'm using VisualWorks 7.6.
>
> Thanks a lot in advance,
> FaQ
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>  


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc