Svdrpsend.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K
 
K
 
(Eine dazwischenliegende Version von einem Benutzer wird nicht angezeigt)
Zeile 3: Zeile 3:
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
 
trap 'exec 5>&-' 2 15
 
  
 
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!
 
exec 5<>/dev/tcp/${HOST:-localhost}/${PORT:-2001} || exit
 
exec 5<>/dev/tcp/${HOST:-localhost}/${PORT:-2001} || exit
 
echo "$ARGS" >&5
 
echo "$ARGS" >&5
cat <&5
+
while read -t 1 i ; do
 +
    echo "$i"
 +
done <&5
 +
exec 5>&-
 
</pre>
 
</pre>
  
 
[[Kategorie:svdrp-anwendungen]]
 
[[Kategorie:svdrp-anwendungen]]

Aktuelle Version vom 19. April 2008, 22:25 Uhr

Erster Versuch, ohne perl.

#!/bin/sh

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
while read -t 1 i ; do
    echo "$i"
done <&5
exec 5>&-