Reputation: 121
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?
Upvotes: 0
Views: 944
Reputation: 212248
Use cat
. If you execute:
cat | script
you can cut-n-paste or type into the tty.
Upvotes: 0
Reputation: 65274
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
Upvotes: 2