聲明當我運行一個名爲anom
一個C
程序,它在腳本返回0
或1
:比較整數值,如果在bash
while :
do
xentop -b -d 1 -i 50 >> out
cpu=$(tail -n 50 out| tr '\r' '\n' | col -bx | awk '{ total += $4 } END { print total/50 }')
echo "$cpu"
echo "$cpu_before"
det=$(./anom $cpu $cpu_before)
cpu_before=$cpu;
echo "$det"
if [ "$det" -eq "1" ];then
echo "Detected"
c=c+1
fi
done
它返回error
線路if [ "$det" -eq "1" ];then
:
[: : integer expression expected
我試過這樣:
if [ "$det" -eq 1 ];then
但我得到相同的錯誤。
它*返回*,或它*輸出*? –
從「$ det」中刪除「」,成爲一個字符串,-eq期望整數。檢查人測試 –
@ Ignacio Vazquez-Abrams:它返回。 – Mjina