我正在学习bash,我想自动化一系列我经常使用的命令。在这种情况下,它是 macchanger,并重新启动网络管理器。
#!/bin/bash
#Automated macchanger script
wlanDOWN=$(ifconfig wlan0 down)
change_mac=$(macchanger -r wlan0)
wlanUP=$(ifconfig wlan0 up)
verify=$(macchanger --show wlan0)
network_connect=$(sudo service network-manager restart)
confirmation=$(dialog --msgbox "Change complete" 10 30)
printf "%sn" "$wlanDOWN"
printf "%sn" "$change_mac"
printf "%sn" "$wlanUP"
printf "%sn" "$verify"
printf "%sn" "To return to permanent mac address type 'macchanger --permanent <interface name>' "
printf "%sn" "$network_connect"
printf "%sn" "$confirmation"
当我执行此脚本时
./hide_me
它只是挂起,直到我第二次按 Enter 键,然后它只显示新的 mac 地址,而不显示我的消息框。有什么指示吗?谢谢朋友们。
删除了对话框,它执行了它应该执行的操作。
#!/bin/bash
#Automated macchanger script
wlanDOWN=$(ifconfig wlan0 down)
change_mac=$(macchanger -r wlan0)
wlanUP=$(ifconfig wlan0 up)
verify=$(macchanger --show wlan0)
network_connect=$(sudo service network-manager restart)
confirmation=$(dialog --msgbox "Change complete" 10 30)
printf "%sn" "$wlanDOWN"
printf "%sn" "$change_mac"
printf "%sn" "$wlanUP"
printf "%sn" "$verify"
printf "%sn" "To return to permanent mac address type 'macchanger --permanent <interface name>' "
printf "%sn" "$network_connect"
我今天学到了一些东西:K.I.S.S. ;-)