I want to write a shell script that does what a recorded macro would do ... replay key-presses. In particular to produce ctrl-a .
Is this possible?
I've tried things like echo \0141 which just says there's no command \0141
-
Have you tried Expect?
From rleir -
In X11, you might be able to make use of
xdotool.xdotool key ctrl+aFrom Dennis Williamson -
When an app is running it often reset terminal characteristics, so that pressing ctrl-a may actually be recorded as ASCII 1. Or a series of keystrokes.
In a console ctrl-v ctrl-a produces the ^A display and you get
echo ^A | od -x 0000000 010awhere 01 is ctrl-a.
So, the point is:
in order to"script" something you have to capture terminal settings, remember them, then reset them during replay. In a shell script this means parsing the output of
stty -aand saving it in a format that lets you send it back to stty during replay, then send your data stream to the terminal.
This is greatly complicated by terminal drivers, graphical interfaces and so on.
To get a "pure" ctrl-a use ctrl-v ctrl-a - only in console, not necessarily inside an editor.
From jim mcnamara
0 comments:
Post a Comment