×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

support utilities

changing the speed of a chozen network interface without a need fro reboot by MoshiachNow
Posted: 11 Nov 04 (Edited 18 Nov 04)

#!/bin/ksh
##########################################################################
#    Updated on 18/11/04
#       Version 1.1        
#      This script  enables changing the speed of a chozen network interface without a need for reboot
#      The script displays a list of the existing ent interfaces with their current speed and IP setting .
#      Once you  choose the interfaces,you then choose the desired speed.
#      WARNING: THIS OPERATION WILL CUT OFF ANY APPLETALK/NFS/TCPIP CONNECTIVITY FOR SEVERAL SECONDS !
#      Note: 1.If you are changing the speed of the default interface - you telnet communication will be cut off for a several
#    seconds  then it will restore back.
#        2. If you work remotely ,then choose the default interface and change it's speed to the one which is not
#    supported by your swith - the script may stick and leave you with a disabled network.Then you have to change the
#    interface settings localy on your machine
#    usage : chent.sh
#####################################################################
CHENT="/scitex/version/scripts/CHENT.sh"
export LOG="/tmp/chent.log"
MYTERM1=`who -m|awk '{ print \$2 }'`                
export MYTERM=/dev/$MYTERM1

#collect all ENTs info into file
for ENT in `lsdev -Cs pci|grep ent | awk '{ print $1 }'`;do
    EN=`echo $ENT|cut -c 1,2,4`
    mktcpip -S $EN 2>&1|grep -v host|awk -F: '{ printf  ("%-4s %-15s %-15s %-12s %-12s ",$4,$2,$3,$5,$7 )}'
        SPEED=`lsattr -El $ENT | grep -i media_ | awk '{ print $2 }'`
        if [[ -z $SPEED ]] ;then
        printf  "%-18s"  ""
        else
                printf  "%-18s" "$SPEED"
        fi
        lsdev -Cspci | grep $ENT|awk  '{print $4,$5}'
done  > /tmp/EN

COUNT=`wc -l /tmp/EN|awk '{ print $1 }'`
integer A=1
oldIFS=$IFS    #change field separator to "end-of-line"
IFS='\n'
while (( $A <= $COUNT )) ;do    #fill up the array from the file
    INTERFACE[A]=`head -n $A /tmp/EN|tail -1`
    A=$A+1
done
A=$A-1

echo "---------------------------------------------------"
IFS='!'    #change field separator to non-existing one just for "select"
echo "\nWARNING: THIS OPERATION WILL CUTT OFF ANY /NFS/TCPIP CONNECTIVITY FOR SEVERALL SECONDS !\n"
echo "---------------------------------------------------"
echo "Select the destination interface : \n"
printf "%-2s %-4s %-15s %-15s %-12s %-11s  %-17s %-20s\n" "  " "Int" "IP_address" "Mask" "DNS" "Gateway"  "Speed" "Type"
printf "%-2s %-4s %-15s %-15s %-12s %-12s %-17s %-20s\n" "  " "---" "----------" "----" "---" "-------" "--------" "----------"

#Select the INTERFACE
PS3="choose the interface >>"
select DEST_INTERFACE in ${INTERFACE[*]}
do
    if [[ -z $DEST_INTERFACE ]]
    then
        printf -- "Choose the right number \n\n"
    else
        break
    fi
done

IFS=$oldIFS    #change field separator back to default !
FINAL_INT=`echo  $DEST_INTERFACE|awk '{print $1}'|cut -c 3`

#Get the specific boards options
if lsdev -Cspci | grep ent$FINAL_INT |grep 3Com >/dev/null ;then
    DEVICE="3C905"
    ATTRIBUTE="media_type"
else
     DEVICE=`lsdev -Cspci | grep ent$FINAL_INT | awk -F "(" '{print $2 }'|tr -d ")"`
     ATTRIBUTE="media_speed"
fi

#Select the speed
odmget -q uniquetype="adapter/pci/$DEVICE" PdAt|grep media_  >/dev/null    #Check if this interface is configurable
if [[ $? != 0 ]] ; then
    echo "\nThis interface speed can not be changed !\n"
    exit
fi

echo "\nSelect the required new speed  :\n"
PS3="choose speed>>"
select SPEED_SET in `odmget -q uniquetype="adapter/pci/$DEVICE" PdAt | grep -p media_ | awk -F \" '/values/ {print $2}' | tr , ' ' ` Exit   ;do
    if [[ -z $SPEED_SET ]] ;then
        printf -- "Choose the right number \n\n"
    elif [[  $SPEED_SET = "Exit" ]] ;then
        exit
    else
        break
    fi
done

echo "\nThis operation may take severall minutes ..."
echo "Now unmounting all NFS mounts ..."
umount allr >/dev/null 2>&1
echo "Now stopping tcpip  ..."
stopsrc -g tcpip  >/dev/null 2>&1
    
#Now create a background script    
echo '#!/bin/ksh'                 >  $CHENT
echo "chdev -l en$FINAL_INT -a state='down' > \$LOG 2>&1"                                >> $CHENT

echo "chdev -l en$FINAL_INT -a state='detach' >> \$LOG  2>&1"                            >> $CHENT
echo "chdev -l ent$FINAL_INT -a $ATTRIBUTE=$SPEED_SET  2>&1 >\$MYTERM |tee -a \$LOG"    >> $CHENT
echo "echo \$? >> \$LOG"                                                            >> $CHENT
echo "if [[ \$? != 0 ]]  ;then "                                                        >> $CHENT
echo "echo \"Failed to change the required speed !\"  >\$MYTERM"                            >> $CHENT
echo "exit 1"                                                                        >> $CHENT
echo "fi"                                                                            >> $CHENT
echo "chdev -l en$FINAL_INT -a state=up  >> \$LOG  2>&1"                                >> $CHENT
echo "Now restarting tcpip and atalk ..."                                                >> $CHENT
echo "mkdev -l inet0 >> \$LOG 2>&1"                                                    >> $CHENT
echo "sleep 1"                                                                    >> $CHENT
echo "startsrc -g tcpip >> \$LOG 2>&1"                                                >> $CHENT
                                    

chmod 777 $CHENT
nohup $CHENT  >$MYTERM 2>/dev/null

echo "The new speed is \c"
lsattr -El ent$FINAL_INT | grep -i media_| awk '{ print $2 }'
echo " "


Back to IBM: AIX FAQ Index
Back to IBM: AIX Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close