2017-05-29 78 views
0

因此,我正在爲Kali Linux編寫一個腳本,它將我的網卡置於監視模式。但是當我試圖運行它時,我遇到了第八行中的do命令的問題。下面是代碼:收起這個Shell腳本什麼是錯誤的

#!/bin/bash 
echo "Preparing to enter monitor mode."` 

檢查,看看Firefox的運行

ps cax | grep firefox > /dev/null 
if [ $? -eq 0 ]; then 
echo "Firefox is running. It needs to be closed in order to properly enter monitor mode." #If it is offers to close it 
echo "Would you like me to close it for you?" 
select yn in "Yes" "No"; do 
case $yn in 
Yes) pkill firefox; echo "Firefox killed. Proceeding to enter monitor mode."; echo "Press any button when ready"; wait;; 
No) echo "Proceeding to enter monitor mode."; echo "Press any button when ready."; wait;; 
else 
echo "Proceeding to enter monitor mode." 
echo "Press any button when ready" 
wait 
fi 

詢問無線接口的名稱設置變量

echo "What is the name of your wireless interface?" 
read interfacevar 
echo Thank you. Entering $interfacevar into monitor mode. 
airmon-ng start $interfacevar 
airmon-ng check kill 
echo "Complete! Exiting in:" 
echo "5" 
sleep 1s 
echo "4" 
sleep 1s 
echo "3" 
sleep 1s 
echo "2" 
sleep 1s 
echo "1" 
sleep 1s 
echo "Goodbye!" 
exit 

但後來我得到的問題說,該做的在第8行是不正確的。

+0

使用[shellcheck.net](http://shellcheck.net)來診斷您的腳本。 – mklement0

回答

1

的問題是,你完成一個case塊與else時,你應該esac

來完成它可以通過前右else

添加一行

esac 

修復

+0

好吧,我不會說謊。我不知道這是什麼意思,我基本上通過做大量的谷歌搜索來設置這個腳本。我需要在腳本中更改它的工作原理嗎? – Darth4212

+0

您正在使用具有特殊語法的複合命令。你可以用'man bash |閱讀sed -n'/^\ s \ {7 \} case /,/ list \。$/p''。或者看看這裏:http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_03.html –