Hotspot logging

Is it possible to log all available hotspots names/signal/… to log once a minute and what is name of currently used hotspot?

Hi cirno,

yes, just load the XNetwork scripting addition, with the “list wireless networks” command you get all information at once.
Then write a stay open script to store the data into a log file periodically

I tried to use this:
list wireless networks

It gives all the info i need (except what is name of current hotspot):
{{signal on noise ratio:31, channel:1, noise:0, signal strength:31, beacon interval:100, network name:“default”, managed:true, ad hoc:false, wep encrypted:false, mac address:“11:22:33:44:55:66”}}

My script is in next post.

hm, here is still the name:
…beacon interval:100, network name:“default”, managed:true, ad hoc:false,… :wink:
you can get the name of the hotspot you’re currently connected with

do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
global logtime
global logname
global shortname

on run
	set shortname to system attribute "USER"
	set logtime to (do shell script "date  +'%y%m%d'" as string)
	set logname to "WiFi"
end run

on loopnow()
	set nowis to (do shell script "date  +'%H%M%S'" as string)
	set savethis to nowis & "
" --\r
	write_to_log(savethis, "Macintosh HD:Users:" & shortname & ":Desktop:" & logtime & " " & logname & " Log.txt", true)
	set savethis to (list wireless networks) & "

" --\r
	write_to_log(savethis, "Macintosh HD:Users:" & shortname & ":Desktop:" & logtime & " " & logname & " Log.txt", true)
end loopnow

on idle
	return 60
end idle

on write_to_log(thiswillbesaved, tothislog, appended_yes)
		set the tothislog to the tothislog as text
		set the open_tothislog to open for access file tothislog with write permission
		if appended_yes is false then set eof of the open_tothislog to 0
		write thiswillbesaved to the open_tothislog starting at eof
		close access the open_tothislog
		return true
	on error
			close access file tothislog
		end try
		return true
	end try
end write_to_log

Hi cirno,

you have to parse the data you get with the “list wireless networks” command, because the result is a list of records
this example extracts channel and name of all received networks

set textList to ""
set WN to list wireless networks
repeat with i in WN
	set {adhoc, beacon, ch, encrypt, macAdress, nName, noi, signalstr, signalONR} to {ad hoc, beacon interval, channel, wep encrypted, mac address, network name, noise, signal strength, signal on noise ratio} of i
	set textList to textList & "Channel: " & ch & return & "Network Name: " & nName & return
end repeat 

PS: you get the path to your desktop much easier with

set Logpath to ((path to desktop) as string) & "Log.txt"