[Newbies] PipeableOSProcess shell interaction
David T. Lewis
lewis at mail.msen.com
Tue Jun 18 03:08:59 UTC 2013
On Mon, Jun 17, 2013 at 04:49:57PM -1000, OpenSlate ChalkDust wrote:
> I tried to use your code but I don't have either class in my 4.3 or 4.4
> images. Do they require adding something?
OSProcess and CommandShell are not part of Squeak, they are externally
maintained packages. You can load them into your standard Squeak image
by opening a SqueakMap browser:
world -> open... -> SqueakMap Catalogue
This will open a SqueakMap Package Loader. You can use this to load the
OSProcess package, then load the CommandShell package.
The PipeableOSProcess and CommandShell classes are both part of the
CommandShell package that you can load from SqueakMap.
> On Mon, Jun 17, 2013 at 1:38 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > On Mon, Jun 17, 2013 at 10:16:05AM -1000, OpenSlate ChalkDust wrote:
> > > On Wed, Jun 12, 2013 at 2:47 AM, David T. Lewis <lewis at mail.msen.com>
> > wrote:
> > >
> > > > On Tue, Jun 11, 2013 at 10:34:47PM -0700, Sean P. DeNigris wrote:
> > > > > When using PipeableOSProcess as a shell, how can I get feedback on
> > the
> > > > status
> > > > > of the individual commands?
> > > > [snip]
> > > > PipeableOSProcess is designed to be part of CommandShell, so when you
> > use
> > > > it
> > > > directly (rather than using a CommandShell), you need to take care of
> > a few
> > > > details. The important things are to set the output pipe for
> > nonblocking
> > > > reads
> > > > (otherwise you will hang up your VM on a read), and to close pipes
> > when you
> > > > are done using them (otherwise you will "leak" file handles over time).
> > > >
> > > > Dave
> > > >
> > > >
> > > Could the example you gave be implemented using CommandShell? In what
> > > situations would I want to use PipeableOSProcess instead of CommandShell?
> > Good question. CommandShell works at a higher level, and it manages the
> > annoying details of closing pipe handles and making sure that you do
> > not block the VM. In most cases, it is easier to use CommandShell rather
> > than operating directly on the lower level PipeableOSProcess.
> > For example (to build on the earlier example), if you want to run the
> > Unix 'ls' command, and check its exit status to determine if a file was
> > not found, it is not necessary to use the lower level PipeableOSProcess.
> > You can do this instead:
> > CommandShell new
> > if: 'cd .. ; ls aFile'
> > then: ['the ls command succeeded']
> > else: ['the file was not found'] ==> 'the file was not found'
> > Having said that, CommandShell is a simple simulation of a Unix shell,
> > and it is not a complete replacement for something like bash. There
> > are cases when you may need to use the features of a real Unix shell,
> > so working directly with a PipeableOSProcess connected to /usr/bin/bash
> > may be necessary in some cases.
> > Dave
> > _______________________________________________
> > Beginners mailing list
> > Beginners at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> Gary Dunn
> Open Slate Project
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners