home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / servers_non_y2 / ag_hostnames next >
Encoding:
Text File  |  2000-03-30  |  713 b   |  35 lines

  1. #!/bin/bash
  2.  
  3. #
  4. # This is a Simpleserver that writes the /etc/yast2rc file
  5. #
  6.  
  7. exec 2>/dev/null
  8.  
  9. while true ; do
  10.     read COMMAND || exit
  11.     case "$COMMAND" in
  12.     "result("*)
  13.         exit
  14.         ;;
  15.     'Read(.)')
  16.         BROADCAST=$(/sbin/ifconfig | sed -n '/.*Bcast:\([0-9.]*\).*/s//\1/p' | head -n 1)
  17.         if [ "$BROADCAST" ] ; then
  18.         IPS=$(ping  -c 2 "$BROADCAST" | sed -n '/.*from \([0-9.]\+\).*/s//\1/p'  | sort -u)
  19.         ANSWER=
  20.         for ip in $IPS ; do
  21.             NAME=$(nslookup $ip | sed -n 's/Name:[[:space:]]*//p')
  22.             NAME=${NAME:-ip}
  23.             if [ -n "$ANSWER" ] ; then ANSWER="$ANSWER," ; fi
  24.             ANSWER="$ANSWER\"$NAME\""
  25.         done
  26.         echo '[' "$ANSWER" ']'
  27.         else
  28.         echo '[]'
  29.         fi
  30.         ;;
  31.     *)
  32.         echo nil
  33.     esac
  34. done
  35.