0

I have continuously running script that waits for input and prints 'Wait for input' every 15 seconds to stdout. I need to emulate action of pasting list of IP addresses in stdin while script is running. For example manually i need to do these steps: copy list below including new line after last list element and paste it directly into stdin.

127.0.0.1
127.0.0.2
127.0.0.3

I've tried using pipes and redirections (with both \n and \r) from file with no luck

echo "127.0.0.1\n127.0.0.2\n" | script

or

script < file

where file contain same ip addresses. Any suggestions?

2
  • Please add the script to your question. Commented Jun 11, 2012 at 13:16
  • What unix is that? Is there a /proc available? Commented Jun 11, 2012 at 13:17

2 Answers 2

2

Use a FIFO!

mkfifo /path/to/tmp.fifo
tail -f /path/to/tmp.fifo | script

Now whenever you send something to the fifo (from another TTY, from a process, whatever), it will be as if you typed into the waiting script, e.g.

echo "127.0.0.1" >> /path/to/tmp.fifo
Sign up to request clarification or add additional context in comments.

Comments

0

Use cat. If you execute:

cat | script

you can cut-n-paste or type into the tty.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.