Content added Content deleted
imported>mutante mNo edit summary |
imported>mutante mNo edit summary |
||
Line 39: | Line 39: | ||
done |
done |
||
</pre> |
</pre> |
||
<pre> |
<pre> |
||
Line 44: | Line 46: | ||
# IPS=$(ifconfig | awk '/inet/ { print $2 }' | awk -F ":" '{ print $2 }') |
# IPS=$(ifconfig | awk '/inet/ { print $2 }' | awk -F ":" '{ print $2 }') |
||
IPS="192.168.23.5 47.45.56.11 189.67.24" |
IPS="192.168.23.5 47.45.56.11 189.67.24.21" |
||
count=0 |
count=0 |
||
for IP in $IPS; |
for IP in $IPS; |
||
do |
|||
do IP[$count]=$IP; |
|||
IP[$count]=$IP; |
|||
echo "Found IP $count - ${IP[count]}"; |
|||
count=`echo $count+1 | bc` |
count=`echo $count+1 | bc` |
||
done |
done |
||
Line 56: | Line 59: | ||
read -p "Which IP do you want to use? (number)" choice |
read -p "Which IP do you want to use? (number)" choice |
||
echo "Your choice was $choice - Setting IP ${IP[ |
echo "Your choice was $choice - Setting ${IP[$choice]} ${IP[choice]}" |
||
</pre> |
</pre> |
Revision as of 01:11, 25 February 2005
#!/bin/bash IPS=$(ifconfig | awk '/inet/ { print $2 }' | awk -F ":" '{ print $2 }') NUMIPS=$(echo $IPS | wc -w) COUNT=1 for i in $IPS do export IP$COUNT=$i COUNT=`expr $COUNT + 1` done # ----------------- # I need to display all ips like this to user: # # 1. 123.123.123.123 # 2. 22.22.22.22 # 3. 32.32.32.222 # # Please choose which IP address to use: # Prompt user here
#!/bin/bash # IPS=$(ifconfig | awk '/inet/ { print $2 }' | awk -F ":" '{ print $2 }') IPS="192.168.23.5 47.45.56.11 189.67.24" count=0 for IP in $IPS; do IP[$count]=$IP; echo "Adding IP$count - $IP"; count=`echo $count+1 | bc` done
#!/bin/bash # IPS=$(ifconfig | awk '/inet/ { print $2 }' | awk -F ":" '{ print $2 }') IPS="192.168.23.5 47.45.56.11 189.67.24.21" count=0 for IP in $IPS; do IP[$count]=$IP; echo "Found IP $count - ${IP[count]}"; count=`echo $count+1 | bc` done read -p "Which IP do you want to use? (number)" choice echo "Your choice was $choice - Setting ${IP[$choice]} ${IP[choice]}"