
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time? And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed? That latter request seems simple, but I didn't get much joy when searching online for likely packages. Thanks Toby Footnotes: * By which I mean, gnome-terminal, xfce-terminal, mate-terminal, etc.

Toby Corkindale <toby.corkindale@strategicdata.com.au> wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
Macro capabilities are usually provided by the application you're running, e.g., Emacs, Vi, Mutt, shell aliases, etc., so I would suggest looking first at what you're using and whether there are better tools for the task that provide the extensibility you need. If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description. Package: expect Version: 5.45-2 Description: Automates interactive applications Expect is a tool for automating interactive applications according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. Expect is also useful for testing these same applications. And by adding Tk, you can also wrap interactive applications in X11 GUIs. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script. Homepage: http://sourceforge.net/projects/expect/

On 16/05/13 12:34, Jason White wrote:
Toby Corkindale <toby.corkindale@strategicdata.com.au> wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
Macro capabilities are usually provided by the application you're running, e.g., Emacs, Vi, Mutt, shell aliases, etc., so I would suggest looking first at what you're using and whether there are better tools for the task that provide the extensibility you need.
The thing is, I'm working on a lot of machines via shell; when I think of it in advance, I script things up in Fabric to be automated, but when I'm just working ad-hoc investigating something, I'd like to be able to automate some common commands. (Not so much shell commands, as commands entered into programs run from the shell)
If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description.
Thanks, however I'm aware of expect. It completely fails my requirement that the terminal remain completely interactive.

Toby Corkindale <toby.corkindale@strategicdata.com.au> wrote:
The thing is, I'm working on a lot of machines via shell; when I think of it in advance, I script things up in Fabric to be automated, but when I'm just working ad-hoc investigating something, I'd like to be able to automate some common commands. (Not so much shell commands, as commands entered into programs run from the shell)
Those programs might have alias capabilities as the shell does, or even just commands to read input from a file.
If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description.
Thanks, however I'm aware of expect. It completely fails my requirement that the terminal remain completely interactive.
In that case, I think you're likelty to be out of luck, which is why I'm strongly suggesting that you rethink what the requirements are and find a better way to solve the problem.

Another idea, I'm sure you could write Emacs Lisp and define key bindings to do this in Emacs shell mode, or even use Emacs macros to do it. That would require running your shell sessions inside Emacs (run in turn from X11 as a GTK application or from a terminal according to your needs).

Alternatively you could look to solve the problem in hardware. If this is a requirement specific to you, rather than for multiple users, you could utilise a keyboard which you can program Macros into, such as the Kinesis and Razer Blackwidow. On Thu, May 16, 2013 at 1:04 PM, Jason White <jason@jasonjgw.net> wrote:
Another idea, I'm sure you could write Emacs Lisp and define key bindings to do this in Emacs shell mode, or even use Emacs macros to do it.
That would require running your shell sessions inside Emacs (run in turn from X11 as a GTK application or from a terminal according to your needs).
_______________________________________________ luv-main mailing list luv-main@luv.asn.au http://lists.luv.asn.au/listinfo/luv-main

On Thu, May 16, 2013 at 12:56:18PM +1000, Toby Corkindale wrote:
On 16/05/13 12:34, Jason White wrote:
Toby Corkindale <toby.corkindale@strategicdata.com.au> wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
Macro capabilities are usually provided by the application you're running, e.g., Emacs, Vi, Mutt, shell aliases, etc., so I would suggest looking first at what you're using and whether there are better tools for the task that provide the extensibility you need.
The thing is, I'm working on a lot of machines via shell; when I think of it in advance, I script things up in Fabric to be automated, but when I'm just working ad-hoc investigating something, I'd like to be able to automate some common commands. (Not so much shell commands, as commands entered into programs run from the shell)
If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description.
Thanks, however I'm aware of expect. It completely fails my requirement that the terminal remain completely interactive.
Huh? You can & off expect scripts - no need to tie up the terminal. Cheers ... Duncan. -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html

On 16/05/13 19:44, Duncan Roe wrote:
On Thu, May 16, 2013 at 12:56:18PM +1000, Toby Corkindale wrote:
On 16/05/13 12:34, Jason White wrote:
Toby Corkindale <toby.corkindale@strategicdata.com.au> wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed? If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description.
Thanks, however I'm aware of expect. It completely fails my requirement that the terminal remain completely interactive.
Huh? You can & off expect scripts - no need to tie up the terminal.
No, I don't want to background the expect script! I mean I want to retain direct control over the terminal, rather than have everything being piped via an Expect script. Since Erik asked, I'll restate my requirements in a different way, a-la "user experience". Are there any X or Terminal apps that can achieve this experience? 1) User clicks icon on desktop to launch terminal window. 2) Terminal window appears 3) User types arbitrary text, maybe running tmux and then sshing to a remote machine. 4) The user accesses a menu on the system which brings up a list of current macros and assigned hot-keys; the user enters in a new macro ("Qwerty"), assigned to the Alt-Q key combination. User closes menu. 5) User presses Alt-Q, and the phrase "Qwerty" appears in the terminal, as if the user had actually typed it themselves. The second/alternative requirements are: 5) User accesses either a menu or a configuration file, which has a list of trigger phrases, and responses. User configures trigger phrase of "hello" to have a response of "world!". 6) The phrase "hello" appears in the terminal as a result of the remote application; the word "world" is then automatically entered into the terminal as if the user had typed it themselves. While I appreciate the various comments regarding Expect and how it could be shoe-horned into this situation, please accept that it's not the right tool and don't mention it further. If what I'm after doesn't exist, that's fine; I just thought I'd ask the community in case it did. (So far, the screen/tmux macros look like the closest hit) Cheers, Toby

On 16.05.13 12:56, Toby Corkindale wrote:
If you ultimately do have to script terminal sessions, the only tool I know of is expect. Here's the Debian package description.
Thanks, however I'm aware of expect. It completely fails my requirement that the terminal remain completely interactive.
Certainty that a thing cannot be done is often the surest guarantee of failure. Is the inadequacy of Expect's "interact" command completely certain? In chapter 15 of O'Reilly's "Exploring Expect" (1996 edition), enough is claimed, to suggest that a skilled scripter could craft a fully interactive interface to multiple applications, with canned responses triggered by user or application input: » The "interact" command is much more flexible than that [chapter 3] example demonstrated. "interact" can also: o execute actions when patterns are seen from either a user or a spawned process o allow the user to take control of a spawned process, and return control to the script for further automated interaction, any number of times o suppress parts or all of an interaction o connect two or more spawned processes together, pairwise or in other combinations « But if the ability to switch between interactive and scripted, plus user or process initiated canned responses, is not enough, then we need a better description of the use-case, I figure. Erik (Who hasn't used this stuff for a decade or so.) -- No one really listens to anyone else, and if you try it for a while you'll see why. - Mignon McLaughlin


On 2013-05-16 12:27, Toby Corkindale wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
That latter request seems simple, but I didn't get much joy when searching online for likely packages.
I can't speak for tmux, but for screen, I do things like the following in my .screenrc: ## Fancy regexp to grep out blank lines and comment lines bind ^g stuff '"^[[:space:]]*(#|$)"' Which says "when I hit the screen escape key followed by ctrl+g, type "^[[:space:]]*(#|$)" (including quotes) into my current screen window. Tmux may have an equivalent to this, assuming this is the sort of thing you're looking for. -- Regards, Matthew Cengia

On 16/05/13 13:50, Matthew Cengia wrote:
On 2013-05-16 12:27, Toby Corkindale wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
That latter request seems simple, but I didn't get much joy when searching online for likely packages.
I can't speak for tmux, but for screen, I do things like the following in my .screenrc:
## Fancy regexp to grep out blank lines and comment lines bind ^g stuff '"^[[:space:]]*(#|$)"'
Which says "when I hit the screen escape key followed by ctrl+g, type "^[[:space:]]*(#|$)" (including quotes) into my current screen window.
Tmux may have an equivalent to this, assuming this is the sort of thing you're looking for.
Thanks - this totally covers one of the two things I was looking for. I can add to .tmux.conf: bind-key C-h send-keys -l "hello world!\n"

On Fri, May 17, 2013 at 01:05:55PM +1000, Toby Corkindale wrote:
On 16/05/13 13:50, Matthew Cengia wrote:
On 2013-05-16 12:27, Toby Corkindale wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
That latter request seems simple, but I didn't get much joy when searching online for likely packages.
I can't speak for tmux, but for screen, I do things like the following in my .screenrc:
## Fancy regexp to grep out blank lines and comment lines bind ^g stuff '"^[[:space:]]*(#|$)"'
Which says "when I hit the screen escape key followed by ctrl+g, type "^[[:space:]]*(#|$)" (including quotes) into my current screen window.
Tmux may have an equivalent to this, assuming this is the sort of thing you're looking for.
Thanks - this totally covers one of the two things I was looking for. I can add to .tmux.conf:
bind-key C-h send-keys -l "hello world!\n" ^^^^^^^^
Hi Toby, What is send-keys? I couldn't find it on Google. Since you have send-keys, you may not need crikey http://www.shallowsky.com/software/crikey/ which provides the ability to assign a key shortcut to a string. The documentation for crikey has improved *a lot* since 0.5, but 0.8.3 is 4 years old now so the promised extras may not be coming any time soon. crikey was expected to be used in conjunction with the window manager to do the key binding, but there is another utility called Keylaunch which can do it for you instead. Do a keylaunch& at the start of your session and it will listen for bound keys (comes with example of binding Shift-Insert). Cheers ... Duncan. -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html

On Sat, May 18, 2013 at 11:13:17AM +1000, Duncan Roe wrote:
crikey was expected to be used in conjunction with the window manager to do the key binding, but there is another utility called Keylaunch which can do it for you instead. Do a keylaunch& at the start of your session and it will listen for bound keys (comes with example of binding Shift-Insert).
Cheers ... Duncan.
Keylaunch can bind *any* command to some key. Hadn't played with crikey for a while - it elicits "semi-stub!" complaints from xterm but otherwise works fine. Cheers ... Duncan. -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html

On 18/05/13 11:13, Duncan Roe wrote:
On Fri, May 17, 2013 at 01:05:55PM +1000, Toby Corkindale wrote:
On 16/05/13 13:50, Matthew Cengia wrote:
On 2013-05-16 12:27, Toby Corkindale wrote:
I just wondered.. are there any terminals*, plugins for terminals, or plugins for tmux, that will scan output and automatically send canned responses -- whilst still letting me interact normally the rest of the time?
And secondly -- are there any tools that will simply let me assign hotkeys or macros to be automatically typed upon being pressed?
That latter request seems simple, but I didn't get much joy when searching online for likely packages.
I can't speak for tmux, but for screen, I do things like the following in my .screenrc:
## Fancy regexp to grep out blank lines and comment lines bind ^g stuff '"^[[:space:]]*(#|$)"'
Which says "when I hit the screen escape key followed by ctrl+g, type "^[[:space:]]*(#|$)" (including quotes) into my current screen window.
Tmux may have an equivalent to this, assuming this is the sort of thing you're looking for.
Thanks - this totally covers one of the two things I was looking for. I can add to .tmux.conf:
bind-key C-h send-keys -l "hello world!\n" ^^^^^^^^
Hi Toby,
What is send-keys? I couldn't find it on Google.
It's present in my version of tmux (1.7), from the man page: send-keys [-lR] [-t target-pane] key ... (alias: send) Send a key or keys to a window. Each argument key is the name of the key (such as ‘C-a’ or ‘npage’ ) to send; if the string is not recognised as a key, it is sent as a series of characters. The -l flag disables key name lookup and sends the keys literally. All arguments are sent sequentially from first to last. The -R flag causes the terminal state to be reset. cheers, Toby
participants (7)
-
Daniel Cross
-
Duncan Roe
-
Erik Christiansen
-
Jason White
-
Matthew Cengia
-
Toby Corkindale
-
trentbuck@gmail.com