How to send a Xterm command via a shell command

Hello,

I would like to send via a shell script a command to my XTerm.

For instance, I would like a shell script of mine to perform the command "clear-saved-lines()" to my Xterm.
Indeed, I don't want to use /usr/bin/clear but a command that erases everything in my xterm.

Thank you,

-- Marc

You can have XTerm translate keystrokes into "actions". (See the man page, search for "Actions"). As an example, you'd add this to your X resource file:

*VT100*translations:    #override <Key>F11: clear-saved-lines()

That means that F11 will execute your function in the Xterm. How do you get such a key to Xterm? First, get the WindowID of your xterm. Then, use xvkbd:

windowID=`sine program`
xvkbd -text "\[F10]" -window $windowID

Does this get you closer to your solution?

Getting the WindowID is, well, it depends on your needs and it's not normally done from the command line. But several solutions exist. You can find these solutions described here and here.

Now it's possible to have a process send keystrokes into another X window.