Changeset 84d8293 in lab.git for iproute/setroute.sh


Ignore:
Timestamp:
Jul 6, 2009 2:49:54 PM (15 years ago)
Author:
mitty <mitty@…>
Branches:
master, trunk
Children:
c8daa69
Parents:
71b798c
Message:
  • FIX: use 'tr' to replace repeated SPACE with a single SPACE before 'cut' lines

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@14 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iproute/setroute.sh

    rc109418 r84d8293  
    1616GATEWAY=$1 
    1717 
    18 TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | cut -d : -f 1` 
     18TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | tr -s ' ' | cut -d : -f 1` 
    1919 
    2020if [ "${PHASE}" = "post-down" ]; then 
     
    3131 
    3232# get IP address, network mask, default gateway info 
    33 IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1` 
     33IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 
    3434if [ -z "${IPADDR}" ]; then 
    3535    # fail to bind IP address to device 
     
    3737    exit 
    3838fi 
    39 NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | cut -d ' ' -f 1` 
     39NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | tr -s ' ' | cut -d ' ' -f 1` 
    4040 
    4141if [ -z "${GATEWAY}" ]; then 
    42     GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | cut -d ' ' -f 3` 
     42    GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 
    4343fi 
    4444if [ -z "${GATEWAY}" ]; then 
    45     GATEWAY=`/sbin/ip route | grep -w default | cut -d ' ' -f 3` 
     45    GATEWAY=`/sbin/ip route | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 
    4646    # this may add wrong default route especially on RHEL 
    4747fi 
Note: See TracChangeset for help on using the changeset viewer.