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 best solutions below
Related Questions in LINUX
- How do I recursively find and replace only in files named index.php on Linux webserver?
- passing text with \n as one argument in shell
- kernel module does not print packet info
- How to send ESC/POS commands to thermal printer in Linux
- (x64 Nasm) Writeline function on Linux
- How do I set the Hive user to something different than the Spark user from within a Spark program?
- Default priority of thread with SCHED_FIFO
- Calling a python function with options from shell script
- How to split a directory into parts without compressing or archiving?
- Cross compile simple standard C program on Linux for Mac
- How to offload NAPI poll function to workqueue
- python netifaces - How to get currently used network interface
- Unexpected output from function
- mingw-64 conflicting declarations when cross-compiling
- Different behavior of async with Visual Studio 2013(Windows8.1) and GCC 4.9(Ubuntu14.10)
Related Questions in SHELL
- passing text with \n as one argument in shell
- Delete the extra space after special character in all the lines of text file
- Calling a python function with options from shell script
- bc: prevent "divide by zero" runtime error on multiple operations
- schedule and automate sqoop import/export tasks
- How can launch an external process from java and still be able to interact with this process?
- Linux find files where mtime and ctime are not equal
- Find all files contained into directory named
- Quick way to remove all folders titled CVS in a directory and it's subdirectories?
- shell process not exiting on `exit` inside `$()`
- How to set environment variables with a forward slash in the key
- System 'bash -ic' stuck when I hit ctrl+c
- bash functions returns "command not found"
- Why does pattern "*.so?(.*)" produce a syntax error in a script but not on command line?
- retrieve plaintext password from file using bash command
Related Questions in SMALLTALK
- Create LineMorph From 100@100 to mouse location in smalltalk
- Double dispatch in Pharo
- Syntax for class and instance variables and methods in Pharo 4.0
- Variable types in smalltalk
- How to Check if objectA has all message as objectB in smalltalk?
- Smalltalk syntax highlighting
- How can I add an item in the World-menu of Pharo 4.0?
- How to get name of superclass according to class in smalltalk
- FFI in Squeak: Singleton ExternalLibrary vs. class methods vs. methods in ExternalStructures?
- Smalltalk - How to avoid typechecks in this situation?
- Smalltalk stdin nextLine for fixed number of lines of input
- Squeak doesn't run on Mac OS Sierra
- Can the ifTrue be omitted from an if in smalltalk?
- How to create an arrow morph in smalltalk80 (squeak) programmatically?
- How to implement instance behaviour (for testing) in Cuis/Squeak/Pharo?
Related Questions in PHARO
- Pharo method with multiple arguments
- Double dispatch in Pharo
- Image freeze when a continuation is called
- Syntax for class and instance variables and methods in Pharo 4.0
- Pharo punctuation marks
- How can I add an item in the World-menu of Pharo 4.0?
- Pharo 5.0 - Cannot play sounds - soundStart: snd_add_pcm_handler: Function not implemented
- How to implement instance behaviour (for testing) in Cuis/Squeak/Pharo?
- How to force finalization (for testing) in Cuis/Squeak/Pharo?
- Pharo image does not recognize middle mouse click on Debian
- ZnSecureServer on Pharo3.0 on Ubuntu
- About deprecation and unit testing in Pharo
- Is there a way to swap control and alt keys in Pharo3.0?
- How to print an integer to transcript
- How to add an entry to context menus in Nautilus?
Related Questions in PHARO-5
- How can we fill a html text area on pharo
- How can I refresh a JSON file for a certain period in pharo
- How can I return a variable contained in a block loop to a method in pharo
- How to do "File in" in Pharo 6.1?
- How do we run a pharo program without instantiating an object in the playground?
- Why does my fresh installed Pharo.image does not save as given in the tutorial?
- How do we deploy a Pharo seaside web application?
- How do we send a canvas image data as an attachment to a server on Pharo?
- Is there a specific way to get the Ip of a computer in Pharo smalltalk?
- Is it possible to write shell command within Pharo smalltalk?
- How do we implement a curl post in pharo
- List of methods if their implementation has at least two occurences of a word 'assert' in Smalltalk
- openWorldWithSpec making it impossible to return to previous windows
- How can I refresh a session for every 60 second and display it on transcript with Pharo?
- Pharo Smalltalk test failure because message not understood
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)
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?
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.