Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 22 Aug 2017, 22:46
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Multi-Wifi-Interface scan and connect "Wifi-Scanner-2" beta
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [21 Posts]   Goto page: Previous 1, 2
Author Message
slavvo67

Joined: 12 Oct 2012
Posts: 1421
Location: The other Mr. 305

PostPosted: Thu 08 Jun 2017, 17:25    Post subject:  

Forgive my ignorance but why more than one wifi interface?
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 1968
Location: In The Way

PostPosted: Fri 09 Jun 2017, 18:31    Post subject:  

I own 5 usb wifi dongles plus the inbuilt pcie. Each card has different sensitivities and I use extension aerial cables to receive scan data from different sides of my building. Scanning with several wifi cards lets me compare the strengths and weaknesses of he cards. Also two interfaces for joining network and creating hotspot. Also just because I wanted to program it.

Eventually i want to develope auto switching between several cards.
Back to top
View user's profile Send private message MSN Messenger 
slavvo67

Joined: 12 Oct 2012
Posts: 1421
Location: The other Mr. 305

PostPosted: Fri 09 Jun 2017, 19:03    Post subject:  

I have a number of wifi dongles, as well. Never thought to use them in that way. I've been wanting to try the hotspot idea for a while.... Any tips?
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 1968
Location: In The Way

PostPosted: Sat 10 Jun 2017, 02:43    Post subject:  

Wifi-HotSpot uses create_ap backend. 'create_ap' gets compiled on first use but the devx must be loaded. Or you can simply cd to /usr/sbin/create_ap-master then open terminal there and
Code:
make install

check installation and get useful info

Code:
create_ap


Wifi-HotSpot gui has information button
xscreenshot-20170610T073644.png
 Description   
 Filesize   29.39 KB
 Viewed   176 Time(s)

xscreenshot-20170610T073644.png

whm.png
 Description   click larger icon for full info.
 Filesize   23.58 KB
 Viewed   175 Time(s)

whm.png

xscreenshot-20170610T073658.png
 Description   
 Filesize   20.43 KB
 Viewed   181 Time(s)

xscreenshot-20170610T073658.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 1968
Location: In The Way

PostPosted: Thu 06 Jul 2017, 15:53    Post subject:  

EDIT: Finally sorted the few inconsistencies that were slowing this app down and otherwise making it less usable!

Code:
#!/bin/sh
# multi-interface wifi scanner and connection app
# copyright (c) 2017 Marcos Contant
#
#
res=`xrandr | cut -f8,9,10 -d' ' | cut -f1 -d',' | head -1 | sed 's/ //g'`
XX=`echo $res | cut -f1 -d'x'`
YY=`echo $res | cut -f2 -d'x'`
pos="+$((XX - 640))+$((YY - YY + 20))"

if [[ "$1" = admin ]]; then
   secs=6
else
   secs=30
fi
interfacefn () {
for wit in `ls /sys/class/net`
do
   case $wit in
      eth0|enp2s0f2) eth=${wit};;
      eth1) eths=${wit};;
      enp0s20u3|usb0) usb0=${wit};;
   esac
done
}

depsfn () { # check dependencies
   dhclu=`busybox which udhcpc`
   dhclu=`echo $dhclu | rev | cut -f1 -d'/' | rev`
   dhcld=`busybox which dhcpcd`
   dhcld=`echo $dhcld | rev | cut -f1 -d'/' | rev`
   if [ -z "$dhcld" ]; then
      dhl1="udhcpc -A 8 -p /var/run/udhcpc.pid -s /etc/udhcpc.script -i"
      dhl2="/etc/udhcpc.script deconfig"
   elif [[ ! -z "$dhcld" ]]; then
      dhl1="dhcpcd"
      dhl3="dhcpcd -z"
      dhl2="dhcpcd -k"
   elif [[ -z "$dhclu" && -z "$dhcld" ]]; then
      zenity --info --text "$dhclu and $dhcld not found"
      echo "$dhclu and $dhcld not found"
   fi
}
depsfn
# Menu activated options for dis/connecting wired interfaces etc
if [[ ! -z "$1" ]]; then
   interfacefn
fi
if [[ "$1" = eth0-u ]]; then
   ifconfig $eth up
   ${dhl3} $eth
   exit 0
fi
if [[ "$1" = eth0-d ]]; then
   ifconfig $eth down
   ${dhl2} $eth
   exit 0
fi
if [[ "$1" = wlan0-d ]]; then
   ifconfig $int down
   ${dhl2} $int
   exit 0
fi
if [[ "$1" = wlan0-u ]]; then
   ifconfig $int up
   ${dhl3} $int
   exit 0
fi
if [[ "$1" = wlan1-d ]]; then
   wlanfn
   ifconfig $int down
   ${dhl2} $int
   exit 0
fi
if [[ "$1" = usb0-u ]]; then
   ifconfig ${usb0} up
   ${dhl3} ${usb0}
   exit 0
fi
if [[ "$1" = usb0-d ]]; then
   ifconfig ${usb0} down
   ${dhl2} ${usb0}
   exit 0
fi
#
# cleanup
rm /tmp/interfaces 2> /dev/null
rm /tmp/interface 2> /dev/null
rm /tmp/net 2> /dev/null
rm /tmp/netsel 2> /dev/null
[[ /tmp/wifitray ]] && /tmp/wifitray 2> /dev/null
rm -f /tmp/wifitray 2> /dev/null
rm -f /tmp/onclick 2> /dev/null
rm -f /tmp/scans* 2> /dev/null

# unst variables
for i in int int1 int2 int3 int4 int5 int6 int7 int8 these1 these2 these3 these4 these5 these6 these7 these8
do
   unset $i 2> /dev/null
done
for i in 0 1 2 3 4 5 6 7 8
do
   if [[ -e /dev/wlan$i ]]; then
      ifconfig wlan$i down
      iproute flush dev wlan$i
      ifconfig wlan$i up
   fi
done

wlanfn () {     # select interfaces to scan with
[[ /tmp/interfaces ]] && rm /tmp/interfaces
inters=`ls /sys/class/net | sed 's/ //g' | grep --invert-match 'lo' | grep --invert-match 'usb' | grep --invert-match 'eth' | grep --invert-match 'ap' | yad --window-icon=/usr/share/pixmaps/wifi24.png --title="Wifi-Scanner-2" --geometry=300$pos --list --separator=' '  --multiple --column="Select Multiple Interface" | tr '\n' ' '`
ret=$?
[[ $ret -eq 1 ]] && exit 0
echo "$inters"
Q=1
for i in  $inters
do
   echo  "int${Q}=${i}" >> /tmp/interfaces
   Q=$((Q + 1))
done
}
wlanfn

menufn () {    #generate tray menu
[[ -f /tmp/wifitray ]] && /tmp/wifitray
pics3=/usr/share/icons/oxygen/22x22/devices
pics2=/usr/share/pixmaps/puppy
pics=/usr/share/pixmaps
scanres=`iwconfig $int | grep --invert-match 'bytes'`

yad --notification --kill-parent \
    --image=/usr/share/pixmaps/wifiS.png --text="$address:
    $scanres" \
    --command="bash -c on_scanclicks" --menu="Wifi-Scanner-2!killall Wifi-Scanner-2!$pics/wirelessx.png|New-Connection!Wifi-Connect!$pics/wifi224.png|Saved Profiles!Wifi-Profiles!$pics/wireless.png|Browser!defaultbrowser!$pics/browser24.png|Re-connect Wifi!Wifi-Scanner-2 wlan0-u!$pics/wifi124.png|Disconnect Wifi!Wifi-Scanner-2 wlan0-d!$pics/wifi124x.png|+Scanner!Wifi-Scanner-2!$pics/wifi224.png|Stop Scanner!killall Wifi-Scanner-2!$pics/wifi224.png|Ethernet connect!Wifi-Scanner-2 eth0-u!$pics3/network-wired.png|Ethernet disconnect!Wifi-Scanner-2 eth0-d!/usr/share/icons/oxygen/22x22/devices/network-wiredx.png|Ethernet 2 connect!Wifi-Scanner-2 eth1-u!$pics3/network-wired.png|Ethernet 2 disconnect!Wifi-Scanner-2 eth1-d!/usr/share/icons/oxygen/22x22/devices/network-wiredx.png|Connect mobile!Wifi-Scanner-2 usb0-u!/usr/share/icons/oxygen/22x22/devices/phone.png|Disconnect mobile!Wifi-Scanner-2 usb0-d!/usr/share/icons/oxygen/22x22/devices/phonex.png|Close Tray!/tmp/wifitray!/usr/share/icons/oxygen/22x22/actions/application-exit.png" &
mpid=$!
task='kill $mpid'
echo "#!/bin/sh
mpid=$mpid
$task
" > /tmp/wifitray
chmod 755 /tmp/wifitray
}

startinfn () {      #prepares interfaces
for tin in $inters
do
yad --geometry=$pos --undecorated --no-buttons --skip-taskbar --text "Resetting $tin" --timeout 2 &
CURRENTIPS=$(ip addr show | grep $tin | grep inet | awk '{print $2}')
ifconfig $int up
ifconfig $tin down
for I in ${CURRENTIPS}; do ip addr del $I dev ${tin}; done 2> /dev/null
ip route flush dev $tin 2> /dev/null
killall -9 ${dhl1} 2> /dev/null
killall -9 wpa_supplicant 2> /dev/null
rm -f /var/db/dhcpcd-${tin}.lease 2> /dev/null
rm -f /var/lib/dhcpcd/dhcpcd-${tin}.lease 2> /dev/null
rm -f /var/db/udhcpc-${tin}.lease 2> /dev/null
rm -f /var/lib/udhcpc/udhcpc-${tin}.lease 2> /dev/null
rm -f /var/run/wpa_supplicant/$tin 2> /dev/null
rfkill unblock $tin 2>/dev/null
ifconfig $tin up 2> /dev/null
done
}
startinfn

startinfn2 () {    #prepares connection interface
for tin in $int1 $int2 $int3 $int4 $int5 $int6 $int7 $int8
do
   yad --geometry=$pos --undecorated --no-buttons --skip-taskbar --text "Resetting $tin" --timeout 2 &
   CURRENTIPS=$(ip addr show | grep $tin | grep inet | awk '{print $2}')
   ifconfig $int up
   ifconfig $tin down
   for I in $CURRENTIPS; do ip addr del $I dev $tin; done 2> /dev/null
   ip route flush dev $tin 2> /dev/null
   rm -f /var/db/dhcpcd-${tin}.lease 2> /dev/null
   rm -f /var/lib/dhcpcd/dhcpcd-${tin}.lease 2> /dev/null
   rm -f /var/db/udhcpc-${tin}.lease 2> /dev/null
   rm -f /var/lib/udhcpc/udhcpc-${tin}.lease 2> /dev/null
   rm -f /var/run/wpa_supplicant/$tin 2> /dev/null
   rfkill unblock $tin 2>/dev/null
   ifconfig $tin up 2> /dev/null
done
}

uhohfn () {    #checks connection profile has data
uhoh=`cat /tmp/netsel`
if [[ -z "$uhoh" ]]; then
   rm -f /tmp/netsel
   $0
   exit 0
fi
}

passwordfn () {     #password username
userdata=`yad --geometry=$pos --window-icon=/usr/share/pixmaps/wifi24S.png --image="/usr/share/pixmaps/wifiS.png" --title "Password for ${netsel1}" --form --field=name --field=Password:H`
password=`echo $userdata | cut -f2 -d '|'`
usernm=`echo $userdata | cut -f1 -d '|'`
}

ocfn () {        #profile templates and save profile

if [[ ! -z "$usernm" && ! -z "$password" ]]; then #open AP template
   echo "ctrl_interface=/var/run/wpa_supplicant
   ap_scan=1
   update_config=1
   network={
   ssid=$netsel1
   bssid=$address
   identity='$usernm'
   password='$password'
   key_mgmt=WPA-EAP
   eap=PEAP
   #ca_cert='/path/to/certificate'
   #phase1='peaplabel=0'
   phase2='auth=MSCHAPV2'
   }
   " | tr "'" '"' > /tmp/netsel
elif [[ ! -z "$password" && -z "$usernm" ]]; then #Password only normal AP
   echo "ctrl_interface=/var/run/wpa_supplicant
   ap_scan=1
   update_config=1
   network={
   ssid=$netsel1
   bssid=$address
   scan_ssid=1
   password='$password'
   #psk=$password1
   key_mgmt=WPA2
   pairwise=CCMP TKIP
   group=CCMP TKIP
   }
   " | tr "'" '"' > /tmp/netsel
elif [[ -z "$password" && -z "$usernm" ]]; then #username and password, two phase authentication aka eduroam
   echo "ctrl_interface=/var/run/wpa_supplicant
   ap_scan=1
   update_config=1
   network={
   ssid=$netsel1
   bssid=$address
   key_mgmt=NONE
   }
   " | tr "'" '"' > /tmp/netsel
fi
# save profiles with ssid+mac
diss=`grep 'ssid="' /tmp/netsel | cut -f2 -d'"'`
if [[ /root/.wifi-connect/profiles/"${diss}" ]]; then
   cat /tmp/netsel > /root/.wifi-connect/profiles/"${diss}"+"${address}"
else
   cat /tmp/netsel > /root/.wifi-connect/profiles/"${diss}"+"${address}"
fi

}

function on_scanclicks() {      #connection information from click on tray icon
OLDIFCONFIG=`ifconfig | grep -e 'ESSID' -e 'bytes' -e 'bssid'|  grep --invert-match '\x00' | rev | cut -f1 -d ':' | rev | tr " " "#"`
echo -en "$OLDIFCONFIG" > /tmp/onscanclicks
TITLE="$(cat /tmp/onscanclicks 2> /dev/null)"
yad --on-top --selectable-labels --geometry "40x20-10-35" --text "$TITLE" --undecorated --no-buttons --skip-taskbar --timeout 4 &
}
export -f on_scanclicks

connectfn () {                #actual connection function
[[ -f /tmp/wifitray ]] && /tmp/wifitray 2>/dev/null
ocfn
if [[ ! -z "${netsel1}" ]]; then
      startinfn
      ranmacfn
      ranmacfn
      ifconfig $int down
      ifconfig $int hw ether $CMD #apply temporary mac address
      ifconfig $int up
      wpa_supplicant -Dwext -i $int -c/tmp/netsel -B  #This is the line that connects to AP
   dep=`busybox which ifplugstatus`
   if [ -z "$dep" ]; then
      yad --geometry=$pos --undecorated --no-buttons --skip-taskbar --top --text "ifplugstatus NOT found. After connecting please install it." --timeout 4
   else
      while true
      do
         state=`ifplugstatus $int | grep -e 'link beat detected'` #check if connected
         if [[ ! -z "$state" ]]; then
            break
         fi
      done
   fi
yad --geometry=$pos --undecorated --no-buttons --skip-taskbar --top-left --text " Requesting ip address for\n '$netsel1' " --timeout 3 &
${dhl3} $int
   while true
   do
      ipad=`ifconfig | grep inet | sed 's/inet addr/ip/g' | grep --invert-match inet6 | grep Bcast | sed 's/         //'` #check for ip address
      if [[ ! -z "$ipad" ]]; then
         yad --geometry=$pos --undecorated --no-buttons --skip-taskbar --top-left --text "Ip address obtained '$ipad'" --timeout 2
         break
      fi
   done
fi
menufn &
if [[ "${netsel1}" = BTWifi-with-FON ]]; then #if AP is btwifi this automates login
   bt &
fi

}
[[ -f /tmp/wifitray ]] && /tmp/wifitray 2>/dev/null

menufn
#main loop for scanning
while [[ -z "$pyp" ]]; do
if [[ "$1" = admin ]]; then
   if [[ ! -z "$int" ]]; then
   #filter out connected wireless card
      inters=`ls /sys/class/net | sed 's/ //g' | grep --invert-match 'lo' | grep --invert-match 'usb' | grep --invert-match 'eth' | grep --invert-match "$int" | grep --invert-match "ap" | tr ' ' '\n'`
   else
   #find all connected wireless cards
      inters=`ls /sys/class/net | sed 's/ //g' | grep --invert-match 'lo' | grep --invert-match 'usb' | grep --invert-match 'eth' | grep --invert-match "ap" | tr ' ' '\n'`
   fi
   echo "$inters"
   Q=1
   for i in $inters
   do
      rfkill unblock $i
      ifconfig $i down
      [[ ! -z "$2" ]] && iwconfig $i mode $2
      ifconfig $i up
      echo "int$Q=$i" >> /tmp/interfaces
      Q=$((Q + 1))
   done
fi

while true
do
   if [[ ! -z "$int" ]]; then
      #wpa_supplicant -Dwext -i $int -c/tmp/netsel -B  #This is the line that connects to AP
      inters=`echo ${inters} | tr ' ' '\n' | grep --invert-match "$int"`
      if [[ -z $inters ]]; then
         wlanfn
      fi
   else
      inters=$inters
   fi
   
   rm /tmp/interfaces
   Q=1
   for i in  $inters
   do
      CURRENTIPS=$(ip addr show | grep $i | grep inet | awk '{print $2}')
      ifconfig $i down
      [[ ! -z "$2" ]] && iwconfig $i mode $2
      for I in $CURRENTIPS; do ip addr del $I dev $i; done 2> /dev/null
      ip route flush dev $i 2> /dev/null
      rm -f /var/db/dhcpcd-${i}.lease 2> /dev/null
      rm -f /var/lib/dhcpcd/dhcpcd-${i}.lease 2> /dev/null
      rm -f /var/db/udhcpc-${i}.lease 2> /dev/null
      rm -f /var/lib/udhcpc/udhcpc-${i}.lease 2> /dev/null
      rm -f /var/run/wpa_supplicant/$i 2>/dev/null
      rfkill unblock $i 2>/dev/null
      ifconfig $i up 2>/dev/null
      echo  "int${Q}=${i}" >> /tmp/interfaces #creates list of interfaces
      Q=$((Q + 1))
   done
   #filter out connected interface from scanning
   if [[ ! -z "$int" ]]; then
      grep --invert-match "$int" /tmp/interfaces > /tmp/interface
      . /tmp/interface
   else
      . /tmp/interfaces
   fi
      ranmacfn
      ifconfig $int down
      ifconfig $int hw ether $CMD #apply temporary mac address
      ifconfig $int up
   #make sure associate interface variables
   int1=${int1}
   int2=${int2}
   int3=${int3}
   int4=${int4}
   int5=${int5}
   int6=${int6}
   int7=${int7}
   int8=${int8}
   
   #label tabs by interface label on gui per interface
   if [[ ! -z "${int1}"  ]]; then
      these1="--tab=${int1}"
   else
      these1=""
   fi
   if [[ ! -z "${int2}" ]]; then
      these2="--tab=${int2}"
   else
      these2=""
   fi
   if [[ ! -z "${int3}" ]]; then
      these3="--tab=${int3}"
   else
      these3=""
   fi
   if [[ ! -z "${int4}" ]]; then
      these4="--tab=${int4}"
   else
      these4=""
   fi
   if [[ ! -z "${int5}" ]]; then
      these5="--tab=${int5}"
   else
      these5=""
   fi
   if [[ ! -z "${int6}" ]]; then
      these6="--tab=${int6}"
   else
      these6=""
   fi
   if [[ ! -z "${int7}" ]]; then
      these7="--tab=${int7}"
   else
      these7=""
   fi
   if [[ ! -z "${int8}" ]]; then
      these8="--tab=${int8}"
   else
      these8=""
   fi
   #these9="--tab=Options"
   
   #make used interface tab empty
   if [[ ! -z "$int" ]]; then
   case $int in
      ${int1}) these1="";;
      ${int2}) these2="";;
      ${int3}) these3="";;
      ${int4}) these4="";;
      ${int5}) these5="";;
      ${int6}) these6="";;
      ${int7}) these7="";;
      ${int8}) these8="";;
   esac
   fi
   
   #accumulate tabs into one variable
   these="${these1} ${these2} ${these3} ${these4} ${these5} ${these6} ${these7} ${these8}"
   
   [[ /tmp/net ]] && rm -f /tmp/net    # remove previously selected network output
   #scan on available interfaces
   [[ ! -z "${int1}" ]] && ecann1=`iwlist ${int1} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=1 --list --separator=';' --editable --column="${int1} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int1} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int1}+/" > /tmp/net &`
   [[ ! -z "${int2}" ]] && ecann2=`iwlist ${int2} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=2 --list --separator=';' --editable --column="${int2} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int2} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int2}+/" > /tmp/net &`
   [[ ! -z "${int3}" ]] && ecann3=`iwlist ${int3} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=3 --list --separator=';' --editable --column="${int3} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int3} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int3}+/" > /tmp/net &`
   [[ ! -z "${int4}" ]] && ecann4=`iwlist ${int4} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=4 --list --separator=';' --editable --column="${int4} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int4} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int4}+/" > /tmp/net &`
   [[ ! -z "${int5}" ]] && ecann5=`iwlist ${int5} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=5 --list --separator=';' --editable --column="${int5} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int5} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int5}+/" > /tmp/net &`
   [[ ! -z "${int6}" ]] && ecann6=`iwlist ${int6} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=6 --list --separator=';' --editable --column="${int6} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int6} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int6}+/" > /tmp/net &`
   [[ ! -z "${int7}" ]] && ecann7=`iwlist ${int7} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=7 --list --separator=';' --editable --column="${int7} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int7} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int7}+/" > /tmp/net &`
   [[ ! -z "${int8}" ]] && ecann8=`iwlist ${int8} scan | grep -e 'ESSID' -e 'Quality' -e 'Address' -e 'key' | sed 's/          //g' | sed 's/   / /g' | sed 's/   / /g' | sed 's/  / /g' | sed 's/Quality=/  /g' | sed 's/level=/    /g' | sed 's/ESSID://g' | sed 's/key:on/~on~/g' | sed 's/key:off/~off~/g' | sed 's/Encryption//g' | sed 's/ Signal//g' | sed 's/- Address: / /g' | sed 's|Cell ...|\n|g' | sed 's/  //'  | sed 's/ - //g' | tac | yad --plug=$$ --tabnum=8 --list --separator=';' --editable --column="${int8} found these APs" --column=Password --column=Quality/Level --column=MAC --column=${int8} --hide-column=5 | cut -f1,2,4 -d';' | sed 's/; /+/g' | sed "s/$/+${int8}+/" > /tmp/net &`
   #notebook tabbed gui
   [[ ! -z "${these1}" ]] && yad --window-icon=/usr/share/pixmaps/leafpad.png --geometry=700x280+$((XX - 700))+$((YY - 320)) --on-top --notebook --key=$$ --title="Wifi-Scanner-2: Multi-Interface-Wifi" --tab-pos=bottom $these --timeout $secs
      ret=$?
      [[ $ret -eq 1 ]] && rm -f /tmp/{netsel,netself,net*,interface} && exit 0 #eit on cancel
      empty=`cat /tmp/net` #check if selection made
      
      #unset variables ready for next loop iteration
    for i in int1 int2 int3 int4 int5 int6 int7 int8 these1 these2 these3 these4 these5 these6 these7 these8
    do
      unset $i
    done
    #parse selected network datafields
      if [[ ! -z "$empty" ]]; then
      netsel1=`grep --invert-match 'null' /tmp/net | head -1 | grep '+' | cut -f1 -d'+'`
      address=`cat /tmp/net | cut -f3 -d'+'`
      int=`cat /tmp/net | cut -f4 -d'+'`
         if [[ ! -z "${netsel1}" ]]|[[ ! -z "$address" ]]; then
        
         profile=`ls /root/.wifi-connect/profiles | grep -w "${netsel1}+${address}"|"${netsel1}"` # search saved profiles for selected AP
         if [[ ! -z "${profile}" ]]; then
            Wifi-Starter Wifi-Profiles & #start Wifi-Profiles script
            sleep 3
            exec $0
            exit
         fi
           ONN=`grep -e '~on~' /tmp/net` # check ap security is on
           if [ ! -z "$ONN" ]; then
            passwordfn
             if [[ ! -z "$ONN" && -z "$password" ]]; then
               yad --geometry=300$pos --undecorated --skip-taskbar --no-buttons --text="AP needs a password: so NOT connecting" --timeout=2 #continue script if no password supplied
               unset int
             else
               connectfn &
             fi
         elif [[ -z "$ONN" ]]; then
            connectfn &
            sleep 2
         fi
         
         fi
     fi
   done
done


Last edited by stemsee on Mon 17 Jul 2017, 19:14; edited 6 times in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 1968
Location: In The Way

PostPosted: Sat 08 Jul 2017, 05:29    Post subject:  

The one thing I would like to add now is a static tab for control options.
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 2 of 2 [21 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0905s ][ Queries: 15 (0.0095s) ][ GZIP on ]