Svdrpsend.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K
 
K
Zeile 8: Zeile 8:
 
while [ $# != 0 ] ; do
 
while [ $# != 0 ] ; do
 
     case $1 in
 
     case $1 in
-d) HOST="$2" ;;
+
        -d) HOST=$2
-p) PORT="$2" ;;
+
            shift 2
  *) ARGS=$ARGS" $1" ;;
+
            ;;
 +
        -p) PORT=$2
 +
            shift 2
 +
            ;;
 +
          *) ARGS=$ARGS" $1"
 +
            shift
 +
            ;;
 
     esac
 
     esac
  shift
 
 
done
 
done
  
test -n "$ARGS" || \
+
if [ "${#ARGS}" = 0 ] ; then
(
+
 
     echo "Usage: $0 options command..."
 
     echo "Usage: $0 options command..."
 
     echo "Options: -d hostname        destination hostname (default: localhost)"
 
     echo "Options: -d hostname        destination hostname (default: localhost)"
 
     echo "        -p port            SVDRP port number (default: 2001)"
 
     echo "        -p port            SVDRP port number (default: 2001)"
 
     exit
 
     exit
)
+
fi
  
 
# Your BASH have to be compiled with /dev/tcp/ support!
 
# Your BASH have to be compiled with /dev/tcp/ support!

Version vom 19. April 2008, 23:02 Uhr

Erster Versuch, ohne perl.

#!/bin/sh

trap 'exec 5>&-' 2 15

while [ $# != 0 ] ; do
    case $1 in
         -d) HOST=$2
             shift 2
             ;;
         -p) PORT=$2
             shift 2
             ;;
          *) ARGS=$ARGS" $1"
             shift
             ;;
    esac
done

if [ "${#ARGS}" = 0 ] ; then
    echo "Usage: $0 options command..."
    echo "Options: -d hostname        destination hostname (default: localhost)"
    echo "         -p port            SVDRP port number (default: 2001)"
    exit
fi

# Your BASH have to be compiled with /dev/tcp/ support!
exec 5<>/dev/tcp/${HOST:-localhost}/${PORT:-2001} || exit
echo "$ARGS" >&5
cat <&5