2017-05-29 77 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 –