Контейнеры Docker не могут обмениваться данными во внешней сети


# example you need wget and your PATH is okay then:
# bash/ksh/.. will return exit code 127 if command not found
# 
# redirect stdin and stderr to the /dev/null = if exist, 
# output is not interesting
wget --help >/dev/null 2>&1
stat=$?   # variable ? include last command exit status
echo "exit status:$stat"
if ((stat == 127 )) ; then # not exist/found
   echo "install wget"
   exit 1
fi
echo "wget exist, continue"

Вы можете также используйте if перед командой, но которая обрабатывает все коды выхода, которые не равны 0.

Вы можете выполнить любую команду и проверить код выхода, используя if

# if command ; then 
#     works fine
# else
#     not so fine
# fi

# negative testing ! = if not exit code 0 then
if ! wget --help >/dev/null 2>&1 ; then
   # give err msg to the stderr and exit 
   echo "install wget / wget didn't work correctly" >&2
   exit 1
fi
echo "wget works fine"

Перед проверкой с помощью if посмотрите первый рабочий код выхода

wget --help
echo $?
# will echo 0 = ok. not 0 is not ok
# if command return not 0, then  you can't test using if, you need
# test using exit value = 127
0
19.02.2019, 12:56
1 ответ

Ааа понял... В группе портов виртуального коммутатора VMware все три должны быть включены :. 1. Беспорядочный режим 2. Изменения MAC-адреса 3. Поддельные передачи

1
28.01.2020, 02:41

Теги

Похожие вопросы