curl
和timeout
的bash脚本。 for element in "${array[@]}"; do
if timeout 2s curl -v "telnet://$element:8888"; then
echo "'$element' connected" && break
fi
done
脚本未进入if循环,我得到以下输出:
* About to connect() to abc001 port 8888 (#0)
* Connected to abc001
* About to connect() to abc002 port 8888 (#0)
* Connected to abc002
* About to connect() to abc003 port 8888 (#0)
* Connected to abc003
数组具有值:
abc001
abc002
abc003
我有一个使用curl和timeout的bash脚本。用于“ $ {array [@]}”中的元素;如果超时2s curl -v“ telnet:// $ element:8888”,该怎么办;然后回显“'$ element'已连接” && break ...
if
的值为true。当您将curl..
更改为echo curl...
时,它将执行if语句。