vieyahn2017 / shellv

shell command test and study
4 stars 1 forks source link

ifconfig cut获取IP地址 #3

Closed vieyahn2017 closed 5 years ago

vieyahn2017 commented 6 years ago

ifconfig eth0 | grep "inet addr"| cut -f 2 -d ":"| cut -f 1 -d " "

vieyahn2017 commented 6 years ago

cat pull_up_v3_container.sh


#!/bin/bash
docker pull 10.183.118.211:5000/dj_simu:V3R2C10_001
docker  ps -a | grep "10.183.118.211:5000/dj_simu:V3R2C10_001" |awk '{print $1}'|xargs docker rm -f {}

ipaddr=`ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " "`

index=0
while [ $index != $1 ]
do
   j=`expr 42001  + $index \* 2`
   k=`expr 42002  + $index \* 2`
   docker run -d -p $j:8088 -p $k:22   10.183.118.211:5000/dj_simu:V3R2C10_001 sh /home/start.sh  $ipaddr  $j &

   echo docker run -d -p $j:8088 -p $k:22  10.183.118.211:5000/dj_simu:V3R2C10_001  sh /home/start.sh $ipaddr $j &
   index=`expr $index + 1`
   #sleep 10
done
vieyahn2017 commented 5 years ago
# 本机ip
host_ip=`ifconfig | grep "inet " | awk '{print $2}' | grep -v "127.0.0.1" | xargs | tr ' ' ','`