我遇到一個問題,我正在做一個bash腳本來檢查兩個IP地址。Bash腳本來檢查兩個IP地址
#!/bin/bash
ping -c4 1.1.1.1 > /dev/null
if [ $? != 1 ]
then
echo "Device1 is up"
else
echo "Device1 is down
但是工作細,我想它來檢查第二個地址,然後即
#!/bin/bash
ping -c4 1.1.1.1 > /dev/null
if [ $? != 1 ]
then
echo "Device1 is up"
else
ping -c4 2.2.2.2 > /dev/null
if [ $? != 1 ]
then
echo "Device2 is up"
else
echo "Device 2 is down"
fi
執行基於結果的命令,但它不工作,我得到
line 14: syntax error: unexpected end of file
請查看:http://www.shellcheck.net/ – Cyrus 2015-04-03 19:19:47
縮進代碼並查看問題。 – Cyrus 2015-04-03 19:29:13