52 lines
830 B
Plaintext
Executable File
52 lines
830 B
Plaintext
Executable File
#!/usr/bin/env retro
|
|
|
|
# Bi-Directional Pipes in Retro
|
|
|
|
|
|
## Configuration
|
|
|
|
Let's set some constants and a string template
|
|
|
|
~~~
|
|
'23 'PORT const
|
|
'localhost 'HOST const
|
|
'telnet_%s:%s 'TEMPLATE const
|
|
~~~
|
|
|
|
And now that we have configurable variables, let's make a template of the shell command we need for `unix:popen`
|
|
|
|
~~~
|
|
PORT HOST TEMPLATE s:format
|
|
~~~
|
|
|
|
We've now got a formatted string on the stack. Probably looks like `telnet materiamagica.com:4000`. Isn't RPN funny?
|
|
|
|
Let's save that for later:
|
|
|
|
~~~
|
|
'SHELL_CMD const
|
|
~~~
|
|
|
|
## Prepare the Shell Command
|
|
|
|
Let's get a file handle:
|
|
|
|
~~~
|
|
SHELL_CMD file:R+ unix:popen
|
|
~~~
|
|
|
|
...and save it as `TELNET_FD`:
|
|
|
|
~~~
|
|
'TELNET_FD const
|
|
~~~
|
|
|
|
## Is This Thing On?
|
|
|
|
~~~
|
|
TELNET_FD file:read s:put
|
|
~~~
|
|
|
|
|
|
I don't have any more time for tonight to keep coding sorry.
|