2

Noobs installation. I've a script which needs to be run after a new WiFi connection is set. Is there any way to run this script automatically once we connect/set WiFi?

1

You can run wpa_cli -a /home/pi/script_to_run_on_connect.sh

#!/bin/sh

IFNAME=$1
CMD=$2

if [ "$CMD" = "CONNECTED" ]; then
    # do stuff on connect.
fi

if [ "$CMD" = "DISCONNECTED" ]; then
    # remove network configuration, if needed
fi
  • Hey Doug, will this script run automatically when we setup WiFi in GUI? – Entrepreneur Mar 30 at 8:31
  • Don't know. My Raspberries run headless. Try it by writing something to syslog. – Dougie Mar 30 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.