Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OS: GNU/Linux

I have a program: hello.c

Executable: hello


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.

share|improve this question
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 Aug 28 '12 at 10:23
I am working on my local console. I just want to execute this code by pressing a key. – Sandeep Singh Aug 28 '12 at 10:38
up vote 1 down vote accepted


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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.