2016-01-28 90 views
0

我只想當我的Docker容器在日誌中有兩個提到的字符串時,我想繼續我的bash腳本..我嘗試了下面的代碼,但似乎無法重新計算變量(使用eval ),因此它保持堅持:檢查wordcount直到循環

number=`docker logs mysql 2>&1 | grep 'mysqld: ready for connections' | wc -l` 

until [ "$number" -eq 2 ]; do 
    sleep 2 
    echo $number 
    eval "$number" 
done 

echo Mysql started and rebooted, continue.. 

回答

0

我固定它是這樣的:

number=0 

until [ "$number" -eq 2 ]; do 
    sleep 2 
    number=`docker logs mysql 2>&1 | grep 'mysqld: ready for connections' | wc -l` 
done