Created
April 13, 2013 08:02
-
-
Save jadeatucker/5377537 to your computer and use it in GitHub Desktop.
Shell script to read commands from a named pipe until terminated
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 | |
# | |
# Read commands from a named pipe until terminated e.g. | |
# | |
# echo 'ls -l' > shell-fifo | |
# | |
set -e | |
FIFO=$1 | |
if [ ! -n "$FIFO" ]; then | |
FIFO="shell-fifo" | |
fi | |
if [ ! -e "$FIFO" ]; then | |
mkfifo $FIFO | |
fi | |
echo "Reading commands from FIFO $FIFO" | |
echo "Use CTRL+C to quit" | |
while true; do | |
sh -c "$(cat $FIFO)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment