I'm working on a bash script to test access points. To end sudo airmon-ng start wlan0 && sudo airodump-ng mon0 -- Ctrl + C needs to be pressed, this cancels the entire script, instead of continuing. How can I get it to continue after Ctrl + C?
# Stop Services To Fix Conflicts
service network-manager stop
service avahi-daemon stop
killall wpa_supplicant
clear
# Scan For Access Points
sudo airmon-ng start wlan0 && sudo airodump-ng mon0
# Restart Networking Services
sudo airmon-ng stop wlan0
sudo aitmon-ng stop mon0
sudo service network-manager start
sudo ifconfig wlan0 up
Set up a trap, like this:
int_trap() {
echo "Ctrl-C pressed"
}
trap int_trap INT
echo "Enter line or press Ctrl-C"
xterm
echo "Continuing the script"
See the bash
manpage for more info and usage examples in e.g. /usr/bin/bashbug. Be careful however, the traps may prevent your script from exit cleanly when it's really needed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With