Script per attivare/disattivare wifi
Inviato: mer, 14 nov 2018 18:52
Salve a tutti.
Ho trovato questo script che permette di attivare/disattivare il wifi con un 2click (salvando lo script come applicazione).
Volevo aggiungere un messaggio quando il wifi viene spento e viene accesso ma quando vado per compilare mi da errore (ho scritto echo "Wifi Acceso" e echo "Wifi Spento" nella riga sotto do shell ma non funziona) .
Come va scritto questo comando?
E' possibile fare in modo che il messaggio si veda per x secondi, diciamo 5 secondi?
Grazie.
Ho trovato questo script che permette di attivare/disattivare il wifi con un 2click (salvando lo script come applicazione).
Volevo aggiungere un messaggio quando il wifi viene spento e viene accesso ma quando vado per compilare mi da errore (ho scritto echo "Wifi Acceso" e echo "Wifi Spento" nella riga sotto do shell ma non funziona) .
Come va scritto questo comando?
E' possibile fare in modo che il messaggio si veda per x secondi, diciamo 5 secondi?
Grazie.
Codice: Seleziona tutto
-- note this assumes your wireless ethernet interface is en1
-- get the correct interface from the menu Apple|About This Mac|Network|Wi-Fi or from terminal using ifconfig -a
try
set makiaeawirelessstatus to do shell script "networksetup -getairportpower en1"
on error
display dialog "The script did not work as intended, please check the networksetup command (in terminal) works on your system. It has been tested on mac os 10.7 (Build 11A459e). Other versions of mac os may not have this command available. Please open the applescript in applescript editor for more details." buttons {"kthxbai"}
end try
if makiaeawirelessstatus is "Wi-Fi Power (en1): On" then
do shell script "networksetup -setairportpower en1 off"
else if makiaeawirelessstatus is "Wi-Fi Power (en1): Off" then
do shell script "networksetup -setairportpower en1 on"
else
display dialog "The script did not work as intended, please check your wireless connection is specified correctly. The default in this script is en1 (please open the applescript in applescript editor for more details)" buttons {"kthxbai"}
end if