send(3tk)
π send(3tk) β or, how to yell across apps π
okay bestie, welcome to the glow-up guide for send, a Tk built-in command. yes it's giving β¨remote executionβ¨, yes it's giving πsecurity nightmare if you're carelessπ, and yes we're gonna get into all of it. buckle up. π
πΈ NAME πΈ
send β execute a command in a different application. literally just vibe-transferring your commands to another app's house. π β¨
π¦ SYNOPSIS π¦
send ?options? app cmd ?arg ...?
π DESCRIPTION π
so here's the tea: this command arranges for cmd (and args, if you brought friends) to be executed in the application named by app. it hands you back the result or the error from that execution, like a little messenger pigeon that actually comes home. ποΈ
app can be the name of any application whose main window is on the display containing the sender's main window. note it does not need to be in the same process β we're crossing process boundaries here, no cap. π
now, the arguments:
- if no
argarguments are present, then the whole command to be executed lives entirely inside thecmdargument. one and done. - if one or more
argsare present, they get concatenated to form the command to be executed, just as for theevalcommand. same energy fr fr.
and if the initial arguments of the command start with -? those get treated as options, bestie. here's what's currently defined π
β¨ OPTIONS β¨
-asyncβ requests asynchronous invocation. meaning:sendcompletes immediately without waiting forcmdto finish in the target application. no result will be available, and errors in the sent command will be ignored. π oh, and if the target application is in the same process as the sending application, then-asyncis justβ¦ ignored. it's giving "sure jan." π-displayofpathName β specifies that the target application's main window is on the display of the window given by pathName, instead of the display containing the application's main window. basically: "not that screen, THIS screen." π₯οΈβ‘οΈπ₯οΈ--β serves no purpose except to terminate the list of options. it's the "ok we're done with options now" flag. you only need it ifappcould contain a leading-character. king of doing the bare minimum, honestly. π
π APPLICATION NAMES π
the name of an application is set initially from the name of the program or script that created the application. you can query and change the name of an application with the tk appname command. that's it, that's the section. short and iconic. π
π« DISABLING SENDS π«
if the send command is removed from an application (e.g. with the command rename send {}) then that application will not respond to incoming send requests anymore, nor will it be able to issue outgoing requests. it's giving ghosting, but on purpose. π»
good news tho: communication can be reenabled by invoking the tk appname command. the friendship is repairable. π«Ά
π₯ SECURITY π₯
okay bestie, this is the part where we get serious. π¨
the send command is potentially a serious security loophole. do not sleep on this.
on Unix, any application that can connect to your X server can send scripts to your applications. and those incoming scripts can use Tcl to read and write your files and invoke subprocesses under your name. that's not a vibe, that's a whole identity theft situation. π
host-based access control such as that provided by xhost is particularly insecure β because it allows anyone with an account on particular hosts to connect to your server, and if disabled it allows anyone anywhere to connect to your server. π
in order to provide at least a small amount of security, Tk checks the access control being used by the server and rejects incoming sends unless:
xhost-style access control is enabled (i.e. only certain hosts can establish connections), and- the list of enabled hosts is empty.
what this means: applications cannot connect to your server unless they use some other form of authorization, such as that provided by xauth. β¨
and under Windows? send is currently disabled. most of the functionality is provided by the dde command instead. different app, different channel. π±
π LIMITATIONS π
under macOS/aqua, the send command works only with interpreters that exist in the same process (these are returned by "winfo interps"). invocations that target an interpreter that exists in another process don't accomplish anything. it's giving "I texted but the message never delivered." π³οΈπ¨
π EXAMPLE π
this script fragment can be used to make an application that only runs once on a particular display. obsessed. π
if {[tk appname FoobarApp] ne "FoobarApp"} {
send -async FoobarApp RemoteStart $argv
exit
}
# The command that will be called remotely, which raises
# the application main window and opens the requested files
proc RemoteStart args {
raise .
foreach filename $args {
OpenFile $filename
}
}
π KEYWORDS π
application, dde, name, remote execution, security, send
and that's the whole send(3tk) manual page, bestie!! π this one shipped with Tk 4.0, and the page itself is dated the same β so yeah, she's an elder but she still eats. π tysm for reading, go forth and send responsibly, and pls pls pls don't leave your X server wide open. iykyk. π
β¨π
π¦ where this page comes from
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms