scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 5d9ca41f6771e10623f833d9ebca7176eb5aeb6b
parent 6d944a6fda34c67dcbcd80a7145479d4351543e6
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 23 Sep 2017 20:09:38 +0200

Use proper file in pickone().

Also ensure that $iface is always up before any operational stuff.

Diffstat:
Msrc/iwpick | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/iwpick b/src/iwpick @@ -9,7 +9,6 @@ connect() { essid=$2 key=$3 - ifconfig $iface up 0 iwconfig $iface essid $essid if [ -n "$key" ]; then tmp=$(mktemp) @@ -35,8 +34,10 @@ die() { } pickone() { - ids=$(iwlist wlan0 scan |grep ESSID |cut -d'"' -f2) - nets=$(cat "$NETWORKS_FILE") + iface="$1" + file="$2" + ids=$(iwlist "$iface" scan |grep ESSID |cut -d'"' -f2) + nets=$(cat "$file") for net in $nets; do essid="$(echo "$net" |cut -d: -f2)" @@ -83,9 +84,10 @@ main() { done [ "$(id -u)" -ne 0 ] && die "You must be root" + ifconfig $iface up if [ $pick -eq 1 ]; then echo "Looking for a suitable network... " - essid=$(pickone) + essid="$(pickone "$iface" "$file")" [ -z "$essid" ] && die "no network found." fi [ -z "$alias" -a -z "$essid" ] && usage