send(n)
π send(n) β the Tk built-in that lets you whisper commands into another app's ear π
Hiii bestie, welcome to the Tk Built-In Commands manual, page send(n). Grab a strawberry matcha, we're learning remote execution today and it's lowkey iconic. πβ¨
β¨ NAME β¨
send β execute a command in a different application. Yes, a different application. It's giving long-distance relationship but make it Tcl. π¦
πΈ SYNOPSIS πΈ
send ?options? app cmd ?arg ...?
π DESCRIPTION π
So here's the tea: send arranges for cmd (and its args) to get executed inside the application named by app. Then it hands you back the result or error from that execution, like a little messenger pigeon that also does receipts. ποΈ
app can be the name of any application whose main window is sitting on the display that contains the sender's main window. And no, it does not need to be in the same process. Different process? Different vibe? Doesn't matter. π«Ά
Now, the command itself:
- If there are no
argarguments, then the whole command to be executed lives entirely inside thecmdargument. - If there's one or more
args, they get concatenated together to form the command to be executed β literally just like theevalcommand does it. Same energy. π«
And if the initial arguments of the command start with -, they're treated as options. Here's what's currently defined, bestie:
-asyncβ requests an asynchronous invocation. In this casesendcompletes immediately without waiting forcmdto finish in the target application. No result will be available, and any errors in the sent command get straight-up ignored. π And if the target application happens to be in the same process as the sending application, then-asyncis just... ignored entirely. Sorry girl. π-displayofpathName β says 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, "hey, look over there." π--β serves no purpose except to terminate the list of options. You only need this one ifappcould contain a leading-character. That's it. That's the whole job. π
π APPLICATION NAMES π
An application's name is set initially from the name of the program or script that created the application. You can query it and change it with the tk appname command. Cute, right? β
π« DISABLING SENDS π«
If send gets removed from an application (like, say, with the command rename send {}), then that application will not respond to incoming send requests anymore, and it won't be able to issue outgoing requests either. Fully off the grid. π§
Good news though: communication can be reenabled by invoking the tk appname command. Glow-up era. π
π SECURITY π
Okay bestie, this is the serious part and I need you to actually read it. π
The send command is potentially a serious security loophole. Not a vibe. Here's why:
On Unix, any application that can connect to your X server can send scripts to your applications. Those incoming scripts can use Tcl to read and write your files and invoke subprocesses under your name. Like, under your name. Ma'am. π
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 it's 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.
This means applications cannot connect to your server unless they use some other form of authorization, such as that provided by xauth. π
Under Windows, send is currently disabled. Most of the functionality is provided by the dde command instead. πͺ
π EXAMPLE π
This script fragment can be used to make an application that only runs once on a particular display. Main character energy, honestly:
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 page, bestie!! This one's from the Tk 4.0 era, page send(n), and honestly? It ate. Now go forth and send responsibly β and maybe double-check your xauth situation first. π
β¨ π
π¦ where this page comes from
- fedora 43: tk 1:9.0.2-2.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk 1:9.0.2-2.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-2.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk 1:9.0.2-2.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- 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