root > WikiSense-trunk > tools > fifoclient

fifoclient

text/x-shellscript, 569 bytes (load raw)
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
    echo "USAGE: fifoclient <fifo> <request> [<request>...]";
    exit 1
fi

s="$1"
shift

f="/tmp/fifoclient-$$.fifo"

mkfifo "$f"
chmod a+w "$f"

while [ ! -z "$1" ]; do
    q="$1&fifo=$f&connection=keep-alive&user-agent=fifoclient+(bash)&separator=*************************&client-pid=$$&client-user=$USER"
    shift
    
    echo "$q" >> "$s"
    if [ "$?" -ne 0 ]; then
        exit 2
    fi
done

q="fifo=$f&connection=close&client-pid=$$&client-user=$USER&method=close"
echo "$q" >> "$s"

cat "$f"
    
echo
rm $f