1
1
OS: GNU/Linux
I have a program: hello.c
Executable: hello
Required:
The executable "hello" is not running.
I press Key "F1".
The executable "hello" automatically runs & produces the ouput (if any).
Please guide me on how to achieve this.
1
1
OS: GNU/Linux
I have a program: hello.c
Executable: hello
Required:
The executable "hello" is not running.
I press Key "F1".
The executable "hello" automatically runs & produces the ouput (if any).
Please guide me on how to achieve this.
1
See https://stackoverflow.com/q/4200800/477035
You can determine the character sequence emitted by a key by pressing
Ctrl-v
at the command line, then pressing the key you're interested in. On my system for F12, I get^[[24~
. The^[
represents Esc. Different types of terminals or terminal emulators can emit different codes for the same key.At a Bash prompt you can enter a command like this to enable the key macro so you can try it out.
bind '"\e[24~":"foobar"'
Now, when you press F12, you'll get "foobar" on the command line ready for further editing. If you wanted a keystroke to enter a command immediately, you can add a newline:
bind '"\e[24~":"pwd\n"'
The man page for bash contains this
bind [-m keymap] -x keyseq:shell-command
bind [-m keymap] keyseq:function-name
If your shell is not bash, I suggest scrutinizing the man page for your preferred shell for equivalent capability.
Are you logged into a local console? Or are you at the local console but not logged in? Or is this supposed to work remotely? Your question is very, very vague. – David Schwartz – 2012-08-28T10:23:26.553
I am working on my local console. I just want to execute this code by pressing a key. – Sandeep Singh – 2012-08-28T10:38:45.573