Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 22 down vote accepted

Just ask cat to concatenate that file with the stdin:

cat cmd - | interactive
share|improve this answer
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 '12 at 22:31
add comment

Your Answer

 
discard

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.