Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ echo

elap=0

ip neigh | sort | while read -r l; do
# Parse parameter
if [ $# -ge 1 ];
then
FILTER=$(awk 'BEGIN{print toupper("'"$1"'")}')
else
FILTER="";
fi

ip neigh | sort | grep "${FILTER}" | while read -r l; do
ip=$(echo "$l" | awk '{print $1}')
ifc=$(echo "$l" | sed -n 's/.* dev \([^ ]*\).*/\1/p')
mac=$(echo "$l" | sed -n 's/.* lladdr \([^ ]*\).*/\1/p')
Expand Down Expand Up @@ -100,9 +108,16 @@ done

THE_END
```

## Usage
Now you can simply run it as `list-clients` and add it as a Custom command (System > Custom commands) to LuCi!<br>
Optionally you can install `iw` or `iwinfo` to if you want your wireless SSID to be resolved as fallback for Iface.

Optional parameter to filter state: you can also run the command, followed by the desired state in any combination of upper or lower case characters.
Example:
```console
list-clients REACHABLE
```


Note that command might not work properly if not run with root privileges.
Also, the `list-clients` itself does not require `bash` to run so after you are done with the install script, you can uninstall bash if you want...
12 changes: 10 additions & 2 deletions list-clients
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ echo

elap=0

ip neigh | sort | while read -r l; do
# Parse parameter
if [ $# -ge 1 ];
then
FILTER=$(awk 'BEGIN{print toupper("'"$1"'")}')
else
FILTER="";
fi

ip neigh | sort | grep "${FILTER}" | while read -r l; do
ip=$(echo "$l" | awk '{print $1}')
ifc=$(echo "$l" | sed -n 's/.* dev \([^ ]*\).*/\1/p')
mac=$(echo "$l" | sed -n 's/.* lladdr \([^ ]*\).*/\1/p')
Expand Down Expand Up @@ -65,4 +73,4 @@ ip neigh | sort | while read -r l; do
[ -z "$owrtIfc" ] && owrtIfc="-"

printf "%-28s %-17s %-34.34s %-25.25s %-22.22s %-10s %-10s\n" "$ip" "$mac" "$vend" "$host" "$owrtIfc ($ifc)" "$meth" "$state"
done
done