I'm having trouble figuring out how to collect input from an externally
executed linux process. The simple example below should, I think let me dump the contents of the directory /etc. The stream type returned by initialStdOut is AttachableFileStream. Sending the contents message to it generates a primitive error, caused I think because the stream's instance variable position turns out to be nil on inspection. p := UnixProcess command: 'ls -l /etc/' s := p initialStdOut s contents What am I doing wrong or missing? Better would be if someone has a simple code snippet the executes an external process and then accepts output from it asynchronously. Thanks. Jim _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Sun, Apr 06, 2008 at 10:47:29PM -0600, Jim O'Connor wrote:
> I'm having trouble figuring out how to collect input from an externally > executed linux process. > > The simple example below should, I think let me dump the contents > of the directory /etc. The stream type returned by initialStdOut is > AttachableFileStream. Sending the contents message to it generates > a primitive error, caused I think because the stream's instance variable > position turns out to be nil on inspection. > > p := UnixProcess command: 'ls -l /etc/' > s := p initialStdOut > s contents > > What am I doing wrong or missing? > > Better would be if someone has a simple code snippet the executes an > external process and then accepts output from it asynchronously. Jim, A good way to do this is to use a PipeableOSProcess, which provides a higher-level wrapper around the UnixProcess and takes care of setting up all the pipes between Squeak and the external process. You will need to load the CommandShell package in addition to the OSProcess package in order to get this. Once you have loaded CommandShell, try inspecting this expression: ProxyPipeline command: 'ls -l /etc' You can read the command output directly from the resulting PipeableOSProcess instance. I am not near a Squeak computer at the moment, so apologies in advance if I have misremembered the details above. In any case, you will find a number of examples on the class side of ProxyPipeline and a few of the other classes in CommandShell and OSProcess. HTH, Dave _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Mon, 2008-04-07 at 16:30 -0400, David T. Lewis wrote: > On Sun, Apr 06, 2008 at 10:47:29PM -0600, Jim O'Connor wrote: > > I'm having trouble figuring out how to collect input from an externally > > executed linux process. > > > > The simple example below should, I think let me dump the contents > > of the directory /etc. The stream type returned by initialStdOut is > > AttachableFileStream. Sending the contents message to it generates > > a primitive error, caused I think because the stream's instance variable > > position turns out to be nil on inspection. > > > > p := UnixProcess command: 'ls -l /etc/' > > s := p initialStdOut > > s contents > > > > What am I doing wrong or missing? > > > > Better would be if someone has a simple code snippet the executes an > > external process and then accepts output from it asynchronously. > > > Jim, > > A good way to do this is to use a PipeableOSProcess, which provides a > higher-level wrapper around the UnixProcess and takes care of setting > up all the pipes between Squeak and the external process. You will > need to load the CommandShell package in addition to the OSProcess > package in order to get this. > > Once you have loaded CommandShell, try inspecting this expression: > > ProxyPipeline command: 'ls -l /etc' > > You can read the command output directly from the resulting > PipeableOSProcess instance. > > I am not near a Squeak computer at the moment, so apologies in advance > if I have misremembered the details above. In any case, you will find > a number of examples on the class side of ProxyPipeline and a few of > the other classes in CommandShell and OSProcess. > > HTH, > > Dave > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners Dave, Thanks. That's just what I was looking for. Jim _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Tue, Apr 08, 2008 at 09:16:57AM -0600, Jim O'Connor wrote:
> > Thanks. That's just what I was looking for. You're welcome! _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |