Consider the interactive program interactive. I have to run this program fairly frequently, and each time I run it the first few commands are the same. Obviously, having to type those commands over and over again is a pain. I have collected those command (separated by newlines) in the file cmd. Now I can do cat cmd | interactive to run the commands. The problem is that once cmd has been fully read, interactive recieves EOF and exits.

What I wish to do is first have interactive read from the pipe (obviously interactive < cmd is also acceptable) and when EOF is received, start reading from the keyboard instead.

1 Answer 1


Just ask cat to concatenate that file with the stdin:

cat cmd - | interactive
  • 1
    The above solution is probably optimal. If you're using a gui desktop, then also take a look at AutoKey. It will let you build macros that can do almost anything you can do from a keyboard. It gets a little tricky if you have to wait for things to happen, or have to get data from the screen, but if you know python (the language its macros are coded in), the sky is the limit.
    – Joe
    Nov 16, 2012 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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