Created
January 29, 2020 13:44
-
-
Save eduardoaugustojulio/8651436bf70c89905450150d38429ac5 to your computer and use it in GitHub Desktop.
named pipes example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pipe="pipe" | |
if [[ ! -p $pipe ]]; then | |
mkfifo $pipe | |
fi | |
while true | |
do | |
if read line <$pipe; then | |
if [[ "$line" == 'quit' ]]; then | |
break | |
fi | |
echo $line | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pipe="pipe" | |
if [[ ! -p $pipe ]]; then | |
echo "Reader not running" | |
exit 1 | |
fi | |
if [[ "$1" ]]; then | |
echo "$1" >$pipe | |
else | |
echo "Hello from $$" >$pipe | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment