Artifact 0a1b20bf99d65466d7cd476996200980144113ee:
Wiki page
[
tkconclient] by
chw
2019-05-16 07:37:26.
D 2019-05-16T07:37:26.169
L tkconclient
P 4c64f0ca6d24ebc25a5712f088f212c2c920b634
U chw
W 3897
<h2>tkconclient</h2>
<tt>tkconclient</tt> is described in the <a href="http://wiki.tcl.tk/14701">Tcl Wiki</a> as means for remote access to another Tcl interpreter using the <a href="http://wiki.tcl.tk/1878"><tt>tkcon</tt></a> console in socket mode.
For an interactive [AndroWish] this can be achieved by adding these lines to <tt>~/.wishrc</tt> (the Tcl script getting sourced when an interactive <tt>wish</tt> or [AndroWish] is started)
<verbatim>
package require tkconclient
tkconclient::start 12345
</verbatim>
meaning that TCP port 12345 is accepting incoming connections from <tt>tkcon</tt> on all interfaces. If the Android device is connected to the development system using an USB cable, it is possible to redirect port 12345 to that USB connection:
<verbatim>
# on development system, instruct adb (Android Debug Bridge from SDK)
# to forward TCP port 12345
adb forward tcp:12345 tcp:12345
</verbatim>
Then <tt>tkcon</tt> can connect in socket mode to <tt>localhost:12345</tt>. Alternatively, the netcat tool <tt>nc</tt> can be used but no input prompts are shown:
<verbatim>
# netcat on development system, either called "netcat" or "nc"
nc localhost 12345
</verbatim>
Alternatively, the <tt>socat</tt> tool can be used similar to netcat:
<verbatim>
# socat on development system
socat TCP:localhost:12345 STDIO
</verbatim>
Even ye good olde <tt>telnet</tt> should do:
<verbatim>
# telnet on development system
telnet localhost 12345
</verbatim>
Similarly, the comm package from tcllib can be used in <tt>~/.wishrc</tt> as
<verbatim>
package require comm
comm::comm new comm::comm -port 12347 -local 1 -listen 1 -silent 1
</verbatim>
where the TCP port used is 12347 on the local interface. The adb redirection in this case is:
<verbatim>
adb forward tcp:12347 tcp:12347
</verbatim>
My own <tt>~/.wishrc</tt> is somewhat larger:
<verbatim>
# Start socket for tkcon
#
# When used over ADB USB debug connection
# the TCP port 12345 must be forwarded using
#
# adb forward tcp:12345 tcp:12345
catch {
package require tkconclient
tkconclient::start 12345
}
# Start socket for comm
#
# When used over ADB USB debug connection
# the TCP port 12347 must be forwarded using
#
# adb forward tcp:12347 tcp:12347
catch {
package require comm
comm::comm new comm::comm -port 12347 -local 1 -listen 1 -silent 1
}
# Start dropbear SSH/SFTP daemon using librun.so
# which is on the path of executable programs and
# located in the directory where all AndroWish
# shared libraries are installed.
#
# When used over ADB USB debug connection
# the TCP port 12346 must be forwarded using
#
# adb forward tcp:12346 tcp:12346
#
# The public key of the development system
# must have been copied to $env(HOME)/.ssh/authorized_keys
# of the Android device. $env(HOME) is usually /data/data/tk.tcl.wish/files
#
# This allows to SSH into the device as the AndroWish user
# or to SFTP to/from the device as the AndroWish user.
# That poor AndroWish user is the uid under which the Android
# package manager decided to install the AndroWish APK.
catch {
exec librun.so libdropbear.so dropbear_main -R -p 12346
}
# Other goodies accessible through librun.so
#
# tclsh: librun.so libtcl.so tclsh ...
# sqlite3: librun.so libtclsqlite3.so sqlite3_shell ...
# ssh: librun.so libdropbear.so cli_main ...
# scp: librun.so libdropbear.so scp_main ...
# dropbearkey: librun.so libdropbear.so dropbearkey_main ...
# curl: librun.so libcurl.so curl_main ...
</verbatim>
Z b6a8992a7c35fe5bcb26b432e8e4e143