# Run a script for hostapd events

**URL:** <https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416>\
**Category:** Installing and Using OpenWrt\
**Created:** [February 15, 2022, 11:23pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416 "2022-02-15T23:23:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![moham\_96](https://forum.openwrt.org/user_avatar/forum.openwrt.org/moham_96/32/3165_2.png) [@moham\_96](https://forum.openwrt.org/u/moham_96)\
**Post date:** [February 15, 2022, 11:23pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416/1 "2022-02-15T23:23:58Z")

</div>

Hi,  
I'm looking to run a script when a user associate/disassociate from the router wifi.  
according to [this](https://forum.openwrt.org/t/solved-assoc-disassoc-event-trigger/3341) thread this can be achieved by using hostapd\_cli, i tried the solution on my linux machine and it works as expected but when running in openwrt i get this error  
`execv: No such file or directory`  
each time a user associate/disassociate from the router and the script is not being executed.  
Is there a better way to get the events (something like ubus or similar?) is the execv error above a bug or something i did wrong ?

Regards

---

<div class="post-metadata">

**Author:** ![anon89577378](https://forum.openwrt.org/letter_avatar/anon89577378/32/6_449c533f586939b6e5f246632a46421f.png) [@anon89577378](https://forum.openwrt.org/u/anon89577378)\
**Post date:** [February 15, 2022, 11:30pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416/2 "2022-02-15T23:30:31Z")

</div>

You need to install the package first...

opkg update  
opkg install hostapd-utils

---

<div class="post-metadata">

**Author:** ![moham\_96](https://forum.openwrt.org/user_avatar/forum.openwrt.org/moham_96/32/3165_2.png) [@moham\_96](https://forum.openwrt.org/u/moham_96)\
**Post date:** [February 16, 2022, 2:16pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416/3 "2022-02-16T14:16:31Z")

</div>

It's already installed

---

<div class="post-metadata">

**Author:** ![moham\_96](https://forum.openwrt.org/user_avatar/forum.openwrt.org/moham_96/32/3165_2.png) [@moham\_96](https://forum.openwrt.org/u/moham_96)\
**Post date:** [February 16, 2022, 8:00pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416/4 "2022-02-16T20:00:16Z")

</div>

ok the problem was because my script has `#!/bin/bash` as a shebang because the script was written and tested on my main linux machine, changing it to `#!/bin/sh` solved the problem

Regards

---

<div class="post-metadata">

**Author:** ![system](https://forum.openwrt.org/uploads/default/original/3X/7/4/740520c71f00039bbf001045c682f0ecb25e905a.png) [@system](https://forum.openwrt.org/u/system)\
**Post date:** [February 26, 2022, 8:01pm UTC](https://forum.openwrt.org/t/run-a-script-for-hostapd-events/120416/5 "2022-02-26T20:01:14Z")

</div>

Closed on February 26, 2022, 8:01pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
