bash input/output redirect problem
Can anyone tell me why the following sometimes works from the command line but refuses to work at all (it hangs) in a shell script file? Is there something buggy about fifo's?
---------------------------- #!/bin/bash rm /tmp/fifo mkfifo /tmp/fifo # create fifo exec 8< /tmp/fifo # open fd 8 for reading exec 9> /tmp/fifo # open fd 9 for writing echo fifocontent >&9 & # dump some content to fifo - don't block script cat <&8 # read content from fifo ---------------------------- bash: 3.1.17(1) on FC6 bash: 2.05b.0(1) on RH9 |
Try putting the exec lines in the background with &. I can't imagine it working on the command line or in the script without the first being in the background.
ta0kira |
Hello!
Command Code:
exec 8< /tmp/fifo Code:
exec 8<>/tmp/fifo Code:
#!/bin/bash P.S.: putting exec in background can't help because new file descriptor is accessible in subshell only (I think). Following script exhibits this behaviour: Code:
#!/bin/bash One can use following approach, though: Code:
#!/bin/bash |
All times are GMT -5. The time now is 04:48 AM. |