Sign up ×
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.

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?

share|improve this question

migrated from Aug 25 '13 at 22:50

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

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 Answer 1

up vote 4 down vote accepted

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
share|improve this answer
Added trap to remove the created file my.fifo once there pipe is closed. – val0x00ff Aug 21 '13 at 14:26
thanks. it works – Farhan Aug 21 '13 at 15:44

Your Answer


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.