Skip to content

Instantly share code, notes, and snippets.

@jadeatucker
Created April 13, 2013 08:02
Show Gist options
  • Save jadeatucker/5377537 to your computer and use it in GitHub Desktop.
Save jadeatucker/5377537 to your computer and use it in GitHub Desktop.
Shell script to read commands from a named pipe until terminated
#!/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