Like in other programming language, is there a way of running linux shell command in Pharo smalltalk or a simple script ? I would like to have my Pharo image running a script that should be able to automate a tasks and return it to some value. I looked at almost all the documentation around and I couldn't find anything related. Maybe It does not allow such functionality.
Is it possible to write shell command within Pharo smalltalk?
1.6k views Asked by ludo At
2
There are 2 answers
Related Questions in LINUX
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- Writes in io_uring do not advance the file offset
- Why `set -o pipefail` gives different output even though the pipe is not failing
- what really controls the permissions: UID or eUID?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Docker container unable to make HTTPS requests to external API
- Whow to use callback_query_handler in Python 3.10
- Create kea runtime directory at startup in Yocto image
- Problem on CPU scheduling algorithms in OS
- How to copy files into the singularity sandbox?
- Android kernel error: undefined reference to `get_hw_version_platform'
- Is there a need for BPF Linux namespace?
- Error when trying to execute a binary compiled in a Kali Linux machine on an Ubuntu system
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
Related Questions in SHELL
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When does Bash read heredocs?
- Why `set -o pipefail` gives different output even though the pipe is not failing
- Run multiple shell scripts in Dockerfile
- Alias does not take effect when I use Vim to execute external commands
- why variable substitution is so different?
- Error: fish: ${ is not a valid variable in fish
- Custom Bash functions & custom statements - Need some advice
- unexpected operator == in square brackets when trying to use gum lib
- Delete first three lines containing a certain word
- Keep the log for the last 14 days
- Iterate over items in one array and groups of items in second array
- Keep multi-version of a static-lib like what we do for shared-libs
- How to write function in bash for reuse shell commands inside using osascript?
- Why is it that when I pass certain directory names to `ls`, sometimes it does not list their contents?
Related Questions in SMALLTALK
- Problem Working with Arrays in Pharo 11.0
- On Pharo 11, is it possible to programatically change the traits of a defined class?
- Smalltalk self issue
- How to define a variable in Strongtalk (Smalltalk) and print it
- Understanding Smalltalk Method Invocation with Multiple Colons
- Convert DateTime to formated String on Pharo 11
- Is there a function to check intersection of two timespans in smalltalk?
- smalltalk difference new & initialise
- Sort array that has different types in smalltalk
- Singleton pattern for multi-processing on Pharo 10.0 ( Smalltalk )
- Which methods must I override to enable drag&drop in Squeak?
- Refreshing a Morph without any user interaction
- Why can't methods have the same name in the same class?
- How is ordered a Dictionary in Pharo?
- Smalltalk Prime Generator with a connected list not working
Related Questions in PHARO
- Problem Working with Arrays in Pharo 11.0
- On Pharo 11, is it possible to programatically change the traits of a defined class?
- how to open a file in windows, from Pharo environment?
- Pharo or Squeak: How to get a list of directories and files in a recursive way
- Convert DateTime to formated String on Pharo 11
- Read nested Json Mapping with NeoJSON
- Overriding and extending trait methods in Pharo
- Singleton pattern for multi-processing on Pharo 10.0 ( Smalltalk )
- How to use commandline tools from within pharo
- How to show test results in the console?
- How to log stack traces from seaside in deployed application
- How is ordered a Dictionary in Pharo?
- Can a child component use updateRoot: to add javascript
- Stream assigment in pharo
- Generateing a method via source code in pharo
Related Questions in PHARO-5
- List of methods if their implementation has at least two occurences of a word 'assert' in Smalltalk
- How to do "File in" in Pharo 6.1?
- How do we send a canvas image data as an attachment to a server on Pharo?
- Is it possible to write shell command within Pharo smalltalk?
- Is there a specific way to get the Ip of a computer in Pharo smalltalk?
- How do we run a pharo program without instantiating an object in the playground?
- How do we deploy a Pharo seaside web application?
- Why does my fresh installed Pharo.image does not save as given in the tutorial?
- How do we implement a curl post in pharo
- What could be wrong with this syntax pharos?
- How do we check in pharo if an element already exist in a set
- How do we write if elseif elseif in pharo?
- How do we iterate and select an element of a set in pharo?
- How can we sort dictionaries in an array by a specific key in pharo?
- How can I return a variable contained in a block loop to a method in pharo
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Pharo does allow the OS interaction. The best way, in my eyes, is to use
OSProcess(as MartinW already suggested).Those that think it is a duplicate are missing this part:
There is nothing about return value in the invoking shell commands from squeak or pharo
To get a return value you would do it the following way:
If you print out the above code you will get most probably a
0as success.If you do an obvious error:
You will get
~= 0value in my case512.Edit adding more details to cover more ground
I agree with eMBee that a statement
is rather vague. I'm adding information about I/Os.
As you may know there are three basic IO:
stdin,stdout, andstderr. These you need to interact with shell. I'll add these examples first then I'll get back to your description.Each of them is represented by instance of
AttachableFileStreamin Pharo. For the abovecommandyou will getinitialStdIn(stdin),initialStdOut(stdout),initialStdError(stderr).To write into the terminal from Pharo:
stdout and stderr (you stream string into terminal)
Check your shell you should see the output there.
stdin - to get what you typed
If you want to grab an output from the command into Pharo a resonable way is to use
PipeableOSProcesswhich, as apparent from his name, can be used in conjunction with pipes.Simple example:
More complex example:
I like the use of
outputAndErrorbecause of typos. If you have an incorrect command you will get the error message:In this case
'/bin/sh: cot: command not found'That is about it.
Update 29-3-2021 The OSProcess works up to Pharo 7. It was not upgraded to work with the changes at Pharo 8 or newer.