Advertisement
s243a

run_iw_scan() - /etc/rc.d/rc.network - pupylinux

Oct 9th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.71 KB | None | 0 0
  1. # lines 214 to 254 of /etc/rc.d/rc.network
  2. # http://www.pearltrees.com/s243a/run-iw-scan-etwork-puppylinux/id16440743
  3. #  Dougal: stick the wireless scan into a function, since we're doing some tricks
  4. #+ to try and ensure it works...
  5. run_iw_scan(){
  6.     # add sleeping a bit for pcmcia...
  7.     #grep -q "^pcmcia:" /sys/class/net/$INTERFACE/device/modalias &&    sleep 5
  8.     #case $INTMODULE in *_cs) sleep 5 ;; esac
  9.     checkIsPCMCIA
  10.     [ -n "$IsPCMCIA" ] && sleep 5
  11.     # no try runing twice and redirecting to files, then use bigger one...
  12.     # clean up any old files
  13.     rm /tmp/iwscan*.tmp 2>/dev/null
  14.     iwlist "$INTERFACE" scan >/tmp/iwscan1.tmp 2>&1
  15.     if [ -n "$IsPCMCIA" ] ; then
  16.       sleep 1
  17.     else
  18.       usleep 100000
  19.     fi
  20.     iwlist "$INTERFACE" scan >/tmp/iwscan2.tmp 2>&1
  21.     ScanListFile=$(du -b /tmp/iwscan*.tmp |sort -n | tail -n1 |cut -f2)
  22.     # now try scanning
  23.     #SCAN_LIST=$(iwlist "$INTERFACE" scan | grep 'Cell\|ESSID\|Mode\|Frequency\|Encryption\|Channel')
  24.     #SCAN_LIST=$(grep 'Cell\|ESSID\|Mode\|Frequency\|Encryption\|Channel' $ScanListFile)
  25.     #rm /tmp/iwscan*.tmp
  26.     ## no, use the file all the time, so just get the cell list
  27.     CELL_LIST=$(grep -Eo "Cell [0-9]+" $ScanListFile | cut -f2 -d " ")
  28.     # if it failed, try sleeping and trying again
  29.     #if [ -z "$SCAN_LIST" ] ; then
  30.     if [ -z "$CELL_LIST" ] ; then
  31.         # with pcmcia try ejecting and inserting (this is done in wag-profiles.sh)
  32.         if [ -n "$IsPCMCIA" ] ; then
  33.             pccardctl eject
  34.             pccardctl insert
  35.             sleep 1
  36.         fi
  37.         sleep 1
  38.         #SCAN_LIST=$(iwlist "$INTERFACE" scan | grep 'Cell\|ESSID\|Mode\|Frequency\|Encryption\|Channel')
  39.         iwlist "$INTERFACE" scan >/tmp/iwscan3.tmp 2>&1
  40.         ScanListFile="/tmp/iwscan3.tmp"
  41.         CELL_LIST=$(grep -Eo "Cell [0-9]+" $ScanListFile | cut -f2 -d " ")
  42.     fi
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement