OSProcess and capturing stdout

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

OSProcess and capturing stdout

Dean Powell
Hi:

I'm using Pharo-1.1 OneClick on Ubuntu 10.04.  One project I am looking at would
require the use of external commands.  It appears I can use something like
"ExternalUnixOSProcess command: 'do_something --option'" etc.  I can perform
external commands, but output from these still goes to stdOut.  I looked into
using CommandShell, but when I try and use this I get grumblings about not
findng PluggableTextController and PluggableTextView.

Using OSProcess or a subclass, is there a way I can launch an external command
but capture the output (say, to a variable)?  Does Pharo yet have the equivalent
of the c popen() command?

Is there a way to load CommandShell without it grumbling about the two packages
mentioned above?

Any information would be appreciated.

Best Regards,
Dean Powell
Edmonton, Canada




_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: OSProcess and capturing stdout

Mariano Martinez Peck
Maybe David can gelp you.


On Fri, Aug 20, 2010 at 9:06 AM, Dean Powell <[hidden email]> wrote:
Hi:

I'm using Pharo-1.1 OneClick on Ubuntu 10.04.  One project I am looking at would
require the use of external commands.  It appears I can use something like
"ExternalUnixOSProcess command: 'do_something --option'" etc.  I can perform
external commands, but output from these still goes to stdOut.  I looked into
using CommandShell, but when I try and use this I get grumblings about not
findng PluggableTextController and PluggableTextView.

Using OSProcess or a subclass, is there a way I can launch an external command
but capture the output (say, to a variable)?  Does Pharo yet have the equivalent
of the c popen() command?

Is there a way to load CommandShell without it grumbling about the two packages
mentioned above?

Any information would be appreciated.

Best Regards,
Dean Powell
Edmonton, Canada




_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users
Reply | Threaded
Open this post in threaded view
|

Re: OSProcess and capturing stdout

Mariano Martinez Peck


On Sun, Aug 22, 2010 at 9:10 PM, David T. Lewis <[hidden email]> wrote:
Mariano,

Please forward this to the Pharo-users list if it does not go through.
I just subscribed a few minutes ago, but I don't know if the mail will
go through yet.


Hi David. Yes, the email went to the mailing list :)

 
Dean,

I have not yet made a ConfigurationOfCommandShell (but I guess that I
should). Mean time you can use a Monticello browser to load the package
directly from SqueakSource. Pharo does not have an MVC environment, and
the errors that you are seeing are a result of this. To avoid the problem
just load the individual CommandShell packages, and do not load the
MVC part. That means that you should load OSProcess first, and then load
just these packages from SqueakSource/CommandShell:


Coool !  you finally split the packages in CommandShell :)
That's good for pharo users.

Thanks david.

mariano

 

 CommandShell-Base
 CommandShell-Commands
 CommandShell-Piping
 CommandShell-UI
 CommandShell-Morphic
 CommandShell-Tests

There is plenty of support for piping in CommandShell. Look through
the class side methods in classes CommandShell and PipeableOSProcess.
The information at http://wiki.squeak.org/squeak/1914 should give a
good overview.

To answer your specific question, popen() is implemented as a primitive
in the OSProcessPlugin, which is distributed with most Unix and Mac
VMs. The primitive is #primitiveCreatePipe, which is called by
UnixOSProcessAccessor>>primCreatePipe. The higher level classes in
OSProcess and CommandShell make use of this to create pipes and
to do things like connecting pipes from external processes (e.g.
the stdout from some command that you might run) to the virtual
machine, thus making it available to the Squeak/Pharo image.

Dave

On Fri, Aug 20, 2010 at 10:06:48PM +0200, Mariano Martinez Peck wrote:
> Maybe David can gelp you.
>
>
> On Fri, Aug 20, 2010 at 9:06 AM, Dean Powell <[hidden email]> wrote:
>
> > Hi:
> >
> > I'm using Pharo-1.1 OneClick on Ubuntu 10.04.  One project I am looking at
> > would
> > require the use of external commands.  It appears I can use something like
> > "ExternalUnixOSProcess command: 'do_something --option'" etc.  I can
> > perform
> > external commands, but output from these still goes to stdOut.  I looked
> > into
> > using CommandShell, but when I try and use this I get grumblings about not
> > findng PluggableTextController and PluggableTextView.
> >
> > Using OSProcess or a subclass, is there a way I can launch an external
> > command
> > but capture the output (say, to a variable)?  Does Pharo yet have the
> > equivalent
> > of the c popen() command?
> >
> > Is there a way to load CommandShell without it grumbling about the two
> > packages
> > mentioned above?
> >
> > Any information would be appreciated.
> >
> > Best Regards,
> > Dean Powell
> > Edmonton, Canada
> >


_______________________________________________
Pharo-users mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-users