How can you invoke shell commands from Squeak and Pharo? Do these environments have anything in them like the system() function in certain unix languages to run external shell commands, or the backticks (can't make them here do to the editor, but what you get when you push the key left of "1" and above "TAB") to capture the output of commands?
相关问题
- Simple class definition error in smalltalk
- Which Smalltalk object should be passed to a C fun
- Squeak(smalltalk) subSrings ignores empty strings
- Smalltalk variables: why should I declare them?
- How to manage 2d array in Smalltalk?
相关文章
- Implementation Strategies for Object Orientation
- What is the difference between Seaside programmmin
- How to copy several Monticello commits from local
- Smalltalk ReferenceStream has problems with new in
- Is it possible to write shell command within Pharo
- Draw table in Pharo
- Draw table in Pharo
- Double dispatch in Pharo
In Squeak you can use CommandShell, but I don't know what (if anything) is available for Pharo at this time.
Shell support in Squeak/Pharo is pretty limited. There are plans to get this improved; see the Coral project. Your contributions are welcome.
I think you can use the package OSProcess to do what you want. In addition, I think is better to ask in squeak-dev or pharo mailing list.
You have two solutions:
Use the package ProcessWrapper. Pros: quick and easy install. Cons: limited functionality, only on win32.
Use the package OSProcess/CommandShell. Pros: pretty good functionality (pipes, environment vars, shell-like workspace ...), and cross platform. Cons: must use VMMaker tools to build the external plugin.
I'm using Windows 10 with Pharo 6, and found it unfeasible to use the
OSProcess
orOSSubprocess
classes (hard to install or the latest versions are not supported for Windows).What does work for me is LibC. You can redirect stderr to a file using
2>
inside the command:It's possible to manipulate the environment variables using (although it returns a value of 1 implying failure in Windows):
However, I was unable to change the current directory:
The workaround is to do CD within the command:
On Windows, there is a wrapper on the Win API allowing you to do this:
There are a lot of support for most of what Windows can do with processes in there (env, ...)
So, look in the catalog for OSWindows.