The basics of interacting with Unix: Difference between revisions
Jump to navigation
Jump to search
(imported material) |
(import + hilight) |
||
Line 1: | Line 1: | ||
* You absolutely need the package <code>OSProcess</code> |
* You absolutely need the package <code>OSProcess</code> |
||
* To get a reference to the process which is running your Cuis image do: |
* To get a reference to the process which is running your Cuis image do: |
||
<syntaxhighlight lang="smalltalk"> |
|||
UnixProcess thisOSProcess . "=> a UnixProcess with pid 14751 " |
|||
</syntaxhighlight> |
|||
⚫ | |||
* Then watch these interactions it should be all clear to you |
* Then watch these interactions it should be all clear to you |
||
<syntaxhighlight lang="smalltalk"> |
|||
⚫ | |||
⚫ | |||
". get the pid of the Cuis process and his father pid " |
|||
UnixProcess thisOSProcess pid. "=> 14751 " |
|||
⚫ | |||
⚫ | |||
". get the pid of the Cuis process and his father pid " |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
". get the environment variables of the shell who run Cuis " |
|||
from here on there are class method shortcuts that let you type less |
|||
UnixProcess env. "=> a Dictionary(#CLUTTER_IM_MODULE->'ibus' #COLORFGBG->'0;15' #COLORTERM->'truecolor' #DBUS_SESSION_BUS_ADDRESS->'unix:path=/run/user/1000/bus' .... #DESKTOP_SESSION->'plasma' #DISPLAY->':0.0' ) " |
|||
⚫ | |||
give you info. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
UnixProcess env. " => a Dictionary(#CLUTTER_IM_MODULE->'ibus' #COLORFGBG->'0;15' |
|||
⚫ | |||
#COLORTERM->'truecolor' #DBUS_SESSION_BUS_ADDRESS->'unix:path=/run/user/1000/bus' .... |
|||
#DESKTOP_SESSION->'plasma' #DISPLAY->':0.0' ) " |
|||
⚫ | |||
⚫ | |||
⚫ | |||
UnixProcess stdOut nextPutAll: 'Hello world ! '. |
|||
⚫ | |||
⚫ | |||
</syntaxhighlight> |
|||
⚫ | |||
UnixProcess arguments . |
|||
⚫ | |||
⚫ | |||
⚫ | |||
but only stderr will go printed into the shell which runs Cuis. " |
|||
UnixProcess stdOut nextPutAll: 'Hello world ! '. |
|||
⚫ |
Latest revision as of 20:35, 12 May 2025
- You absolutely need the package
OSProcess
- To get a reference to the process which is running your Cuis image do:
UnixProcess thisOSProcess . "=> a UnixProcess with pid 14751 "
- Then watch these interactions it should be all clear to you
". get the current working directory of the shell when it run Cuis "
UnixProcess thisOSProcess getCwd. "=> '/home/p/prog/cuis-project' "
". get the pid of the Cuis process and his father pid "
UnixProcess thisOSProcess pid. "=> 14751 "
UnixProcess thisOSProcess ppid. "=> 14750 "
" ------------
from here on there are class method shortcuts that let you type less but the idea is alwys the same you are asking 'UnixProcess thisOSProcess' to give you info.
------------ "
". get the environment variables of the shell who run Cuis "
UnixProcess env. "=> a Dictionary(#CLUTTER_IM_MODULE->'ibus' #COLORFGBG->'0;15' #COLORTERM->'truecolor' #DBUS_SESSION_BUS_ADDRESS->'unix:path=/run/user/1000/bus' .... #DESKTOP_SESSION->'plasma' #DISPLAY->':0.0' ) "
". the program name corresponding to Cuis, which is the name of the OpenSmalltalkVM"
UnixProcess programName . "=> './sqcogspur64linuxht/lib/squeak/5.0-202003021730/squeak' "
" . the VM arguments, where there is Cuis image file and some extra parameters "
UnixProcess arguments . "=> #('Cuis-Smalltalk-Dev/Cuis5.0-4975.image' '-d' 'Preferences veryBigFonts.') "
". get stdin, stdout, stderr "
". observe that by default, as of now, stdout and stderr are both copied to Transcript but only stderr will go printed into the shell which runs Cuis. "
UnixProcess stdOut nextPutAll: 'Hello world ! '.
UnixProcess stdErr nextPutAll: 'Hello world ! '.