"함수 is ipmiping()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
3번째 줄: 3번째 줄:
==Bash==
==Bash==
[[category: bash]]
[[category: bash]]
<source lang='bash'>
<syntaxhighlight lang='bash'>
PING_TIMEOUT=2
PING_TIMEOUT=2
PING_HOST=8.8.8.8
PING_HOST=8.8.8.8
9번째 줄: 9번째 줄:
echo $IS_IPMIPING
echo $IS_IPMIPING
# 0
# 0
</source>
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
*Linux
*Linux
<source lang='php'>
<syntaxhighlight lang='php'>
function is_ipmiping($host, $timeout = 2) {
function is_ipmiping($host, $timeout = 2) {
return exec("ping -c1 -t$timeout $host | grep 'in time' | awk '{print $4}'");
return exec("ping -c1 -t$timeout $host | grep 'in time' | awk '{print $4}'");
}
}
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[함수 is_ping()]]
*[[함수 is_ping()]]
*[[리눅스 ipmiping]]
*[[리눅스 ipmiping]]

2020년 11월 2일 (월) 02:36 기준 최신판


1 Bash[ | ]

PING_TIMEOUT=2
PING_HOST=8.8.8.8
IS_IPMIPING=`ipmiping -c1 -t$PING_TIMEOUT $PING_HOST | grep 'in time' | awk '{print $4}'`
echo $IS_IPMIPING
# 0

2 PHP[ | ]

  • Linux
function is_ipmiping($host, $timeout = 2) {
	return exec("ping -c1 -t$timeout $host | grep 'in time' | awk '{print $4}'");
}

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}