https://github.com/flightaware/tcl-ip-console
provides telnet access to the Tcl interpreter of long-running, event-driven programs
https://github.com/flightaware/tcl-ip-console
Last synced: 4 months ago
JSON representation
provides telnet access to the Tcl interpreter of long-running, event-driven programs
- Host: GitHub
- URL: https://github.com/flightaware/tcl-ip-console
- Owner: flightaware
- License: bsd-3-clause
- Created: 2014-11-13T15:02:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-11-06T22:41:35.000Z (over 7 years ago)
- Last Synced: 2025-10-11T00:05:51.727Z (9 months ago)
- Language: Tcl
- Size: 5.86 KB
- Stars: 5
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tcl-ip-console
---
The Tcl IP Console is an Itcl class that can generate a server socket on a specified TCP port of a machine and will accept connections on that port from localhost (127.0.0.1) only and execute whatever it receives from the socket in the Tcl interpreter and return whatever it receives from the Tcl interpreter back to the socket, along with the execution status, like "ok" or "error".
The Tcl program having the IP console added to it must principally use the Tcl event loop. That is, the Tcl event loop needs to be running via "vwait" or that it is a Tk program or something for the IP console to work.
Usage
---
Add to your program something like...
```
package require fa_console
IpConsole console
console setup_server -port 8888
```
Accessing
---
Once your program is up and running, you can connect to the specified TCP port with nc, telnet or some other program, as in
```
nc localhost 8888
```
You will receive a greeting from the program, something that includes the program name ($::argv0), something like
```
$ nc localhost 8888
connect {foo.tcl - connect from 127.0.0.1 44088 - help for help}
set forever true
ok true
```
Using
---
Whatever you type will be evaled at the top level of the running Tcl interpreter and the results will be sent back to the connection, along with whether the thing worked OK or whether there was an error.
For instance...
```
xset foo bar
error {invalid command name "xset"}
```
...or...
```
set foo bar
ok bar
```
You can poke around with stuff like "info globals", run procs from the command line and so forth.
One thing to note, though, "puts $foo" will not push the contents of the foo variable to your console session but will instead write it to whatever your program's standard output is pointed to.
For the above example if you want the contents of foo, use "return $foo" to get it sent to your console session.
Interesting Tidbits
---
Multiple concurrent sessions are support.
Since the IP console is an Itcl class, multiple IP consoles can be defined in a single program. However, I don't know what that would be good for.