I want to script these few lines

mkfifo my.fifo
cat >my.fifo &
cat my.fifo | nc remotehost.tld 10000

But the line

cat >my.fifo &

When i run it manually it works, but not through bash shell. what could be the reason for it?

migrated from serverfault.com Aug 25 '13 at 22:50

This question came from our site for system and network administrators.

  • 1
    what do you mean "when you run it through bash shell"? What shell are you using when you run it manually? Your question (as phrased) doesn't make sense... – voretaq7 Aug 21 '13 at 13:58

1) Create the first file


mkfifo my.fifo
trap 'rm -f my.fifo' EXIT

cat  <my.fifo &
cat >my.fifo;
nc localhost 2345

2) From another terminal

cat >my.fifo
  • Added trap to remove the created file my.fifo once there pipe is closed. – Valentin Bajrami Aug 21 '13 at 14:26

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.