abilitare e disabilitare wireless da telnet agpf 452

  • 5 Risposte
  • 5714 Visite

0 Utenti e 1 Visitatore stanno visualizzando questo topic.

Offline fiorenontaglio

  • Nuovo Iscritto
  • *
  • 5
come faccio ad accendere e spegnere il wireless da telnet?
(agpf 4.5.2)

ho provato:
conf set /dev/wl0/enabled 0   (oppure 1)
conf reconf 1

non funziona niente!

qualche idea?


grazie
ciao


Offline natalinux

  • VIP
  • *****
  • 9306
  • Sesso: Maschio
Re:abilitare e disabilitare wireless da telnet agpf 452
« Risposta #1 il: 29 Giugno 2011, 22:32 »
Non lo puoi disabilitare dal menù del router?
•••─ ─ ─••• •••─ ─ ─••• •••─ ─ ─•••
TG789vac v2Ver. Mint (17.2) gui 9.6.97 (Tim)
AGTHP_2.3.5 ver. Damson (19.4) DGA4132 [DEV]9.6.97(Tim)
ZTE H388X AGZHP_1.2.3
NordVPN

Offline fiorenontaglio

  • Nuovo Iscritto
  • *
  • 5
Re:abilitare e disabilitare wireless da telnet agpf 452
« Risposta #2 il: 29 Giugno 2011, 23:09 »
si ma vorrei fare un piccolo script di accensione e spegnimento evitando l'interfaccia

Offline pumasognatore

  • Membro Giovane
  • **
  • 77
Re:abilitare e disabilitare wireless da telnet agpf 452
« Risposta #3 il: 03 Luglio 2011, 15:24 »
prova da telnet con il comando:  wlctl down
ovviamente per farlo ripartire sarebbe: wlctl up

sono comandi dell'aga, ma mi pare di aver letto che funziona anche sull'agpf

Offline fiorenontaglio

  • Nuovo Iscritto
  • *
  • 5
Re:abilitare e disabilitare wireless da telnet agpf 452
« Risposta #4 il: 07 Agosto 2011, 22:52 »
ciao...
no non funziona quel comando, ho provato anche a vedere la sezione 802.1x da telnet ma niente da fare (il device dovrebbe essere wl0 ma non riesco ad attivarlo a linea di comando),

però

ho installato iMACRO su firefox (un addon per creare macro in firefox) e con questo stupendissimo script in vbs che ho scritto vado alla stra grande,
quindi ecco cosa fare

1. installare iMACRO su ff https://addons.mozilla.org/it/firefox/addon/imacros-for-firefox/

2. creare la macro ATTIVA WIRELESS (cambiare url del router e LAMIAPASSWORD):
Codice: [Seleziona]
VERSION BUILD=7300701 RECORDER=FX
TAB T=1
URL GOTO=http://192.168.77.1/
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Avanti<SP>>
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:form_contents ATTR=NAME:password_* CONTENT=LAMIAPASSWORD
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Accedi
TAG POS=1 TYPE=IMG ATTR=ID:img55
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Attiva
FRAME F=0
TAG POS=1 TYPE=IMG ATTR=ID:img33
TAB CLOSEALLOTHERS
TAB CLOSE

2. creare la macro DISATTIVA WIRELESS (cambiare url del router e LAMIAPASSWORD):
Codice: [Seleziona]
VERSION BUILD=7300701 RECORDER=FX
URL GOTO=http://192.168.77.1/
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Avanti<SP>>
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:form_contents ATTR=NAME:password_* CONTENT=LAMIAPASSWORD
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Accedi
TAG POS=1 TYPE=IMG ATTR=ID:img55
FRAME F=1
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Configura<SP>Rete<SP>Wi-Fi
TAG POS=1 TYPE=INPUT:RADIO FORM=NAME:form_contents ATTR=ID:radio_interface_active_0
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Salva
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:form_contents ATTR=VALUE:Avanti<SP>>
FRAME F=0
TAG POS=1 TYPE=IMG ATTR=ID:img33
TAB CLOSEALLOTHERS
TAB CLOSE

3. creare wireless.vbs con questo contenuto (è adatto alle mie esigenze, ma dovrebbe andar bene a tutti: cambiare solamente le url del router nella Sub CheckRouterState):
Codice: [Seleziona]
'AliceWireless

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSystemEnv = WshShell.Environment( "SYSTEM" )

If WScript.Arguments.Count = 0 Then
ExecTime = "poweredon"
Else
ExecTime = WScript.Arguments(0)
End If

If wshSystemEnv( "WIRELESS" ) = "on" Then
'caso di wireless on

If ExecTime = "startup" Then
'startup: aspetta almeno 3 minuti

HaveYouWaited(2)

End If

If (ExecTime = "startup" or ExecTime = "poweredon") Then
'startup o durante il lavoro: chiede ed eventualmente spegne

CheckRouterState

Msg = MsgBox("Lasciare attivato il Wireless?",4,"WLan Control")

If Msg = 6 Then
Wscript.Quit(1)
Else
Wireless("Off")
End If

'altrimenti significa che ExecTime = "shutdown", quindi lasciamo acceso
End If

ElseIf wshSystemEnv( "WIRELESS" ) = "off" Then
'caso di wireless off

CheckRouterState

If ExecTime = "shutdown" Then
'in chiusura riaccende
Wireless("On")
Else
'altrimenti chiede ed eventualmente attiva
Msg = MsgBox("Attivare il Wireless?",4,"WLan Control")

If Msg = 6 Then
Wireless("On")
End If

End If

Else
'installazione: creo var d'ambiente WIRELESS se non esiste

Msg = MsgBox ("Il Wireless è attivo in questo momento?",4,"Installazione WLan Control")

If Msg = 6 Then
wshSystemEnv( "WIRELESS" ) = "on"
Else
wshSystemEnv( "WIRELESS" ) = "off"
End If

Msg = MsgBox ("Riavviare lo script per attivare il controllo Wireless",0,"Installazione WLan Control")

End If


Sub Wireless( ByVal switch )
'accende o spegne il wireless mediante FireFox iMACRO

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSystemEnv = WshShell.Environment( "SYSTEM" )

If switch = "Off" Then
WshShell.CurrentDirectory = "C:\Programmi\Mozilla Firefox"
command = "firefox.exe -new-window ""javascript:window.resizeTo(800,600)"""
WshShell.Run command, 1

WScript.Sleep 1000

command = "firefox.exe -new-tab http://run.imacros.net/?m=DISATTIVA%20WIRELESS.iim"
WshShell.Run command, 0

wshSystemEnv( "WIRELESS" ) = "off"

Else
'switch = On
WshShell.CurrentDirectory = "C:\Programmi\Mozilla Firefox"
command = "firefox.exe -new-window ""javascript:window.resizeTo(800,600)"""
WshShell.Run command, 0

WScript.Sleep 1000

command = "firefox.exe -new-tab http://run.imacros.net/?m=ATTIVA%20WIRELESS.iim"
WshShell.Run command, 0

wshSystemEnv( "WIRELESS" ) = "on"

End If

Set WshShell = Nothing
Set WshSystemEnv = Nothing

End Sub

Sub CheckRouterState
'controlla se il router è funzionante ed eventualmente aspetta la sua operatività

If PingSite("192.168.77.1") = False Then

Msg = MsgBox("Il Router è spento o in fase di accensione." & Chr(13) & Chr(10) & "Attendo operatività del router per controllo del Wireless?",4,"WLan Control")

If Msg = 6 Then
Do While PingSite("192.168.77.1") = False
WScript.sleep 1000
Loop
Else
Wscript.Quit(1)
End If

End If

End Sub

Sub HaveYouWaited( byVal minutes )
'guarda da quanto è acceso il pc ed eventualmente aspetta fino al numero di minuti dichiarato

Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_OperatingSystem", , 48 )

For Each objItem in colItems
numUptime  = DateDiff( "s", _
ParseDat( objItem.LastBootUpTime ), _
ParseDat( objItem.LocalDateTime ) )
Next

If numUpTime < (minutes * 60) Then
Wscript.sleep ( ( (minutes * 60) - numUpTime ) * 1000 )
End If

End Sub

Function ParseDat( ByVal strDate )
'restituisce la data da oggetti di sistema

strYear  = Left( strDate, 4 )
strMonth = Mid( strDate,  5, 2 )
strDay   = Mid( strDate,  7, 2 )
strDat   = strDay & "-" & strMonth & "-" & strYear
strHour  = Mid( strDate,  9, 2 ) - strTimeShift
strMins  = Mid( strDate, 11, 2 )
strTime  = strHour & ":" & strMins
ParseDat = strDat & " " & strTime

End Function

Function PingSite( myWebsite )
' This function checks if a website is running by sending an HTTP request.
' If the website is up, the function returns True, otherwise it returns False.
' Argument: myWebsite [string] in "www.domain.tld" format, without the
' "http://" prefix.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
Dim intStatus, objHTTP

Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

objHTTP.Open "GET", "http://" & myWebsite & "/", False
objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

On Error Resume Next

objHTTP.Send
intStatus = objHTTP.Status

On Error Goto 0

Set objHTTP = Nothing

If intStatus = 200 Then
PingSite = True
Else
PingSite = False
End If

End Function
(Testato su Xp / Firefox 5 / Agpf 452)


Con questa roba controllo il Wireless facendo doppio clic su wireless.vbs rispondendo comodamente alle finestrelle "Vuoi attivare il Wireless?" o "Vuoi lasciarlo acceso?", ecc...

ciao
« Ultima modifica: 08 Agosto 2011, 23:08 da fiorenontaglio »

Offline fiorenontaglio

  • Nuovo Iscritto
  • *
  • 5
Re:abilitare e disabilitare wireless da telnet agpf 452
« Risposta #5 il: 02 Ottobre 2011, 22:15 »
Ciao, torno nuovamente sull'argomento postando un nuovo script per accendere e spegnere il wi-fi senza accedere all'interfaccia del pannello di controllo da browser.
Ho perfezionato quanto scritto nel post precedente, infatti non occorrono componenti aggiuntivi per firefox o altri software, basta:

1) copiare il codice seguente in un file di testo con estensione .vbs, per es.: wireless.vbs
2) mettere i valori giusti alle due costanti iniziali IP_DEL_ROUTER_ALICE e PASSWORD_DEL_ROUTER_ALICE

Controllare il wireless del router eseguendo lo script vbs con doppio clic
(per esperti: lo script prevede anche gli argomenti startup e shutdown per esecuzioni automatiche accensione/spegnimento pc)  

Questo script è testato solo per Alice Gate 2 plus Wifi versione 4.5.2 e Windows Xp

Codice: [Seleziona]
'Wireless control

'modificare i valori delle due costanti qui
Const IP_DEL_ROUTER_ALICE = "192.168.1.1"
Const PASSWORD_DEL_ROUTER_ALICE = "la mia password"
'fine modifiche

Dim ExecTime, Browser
Set WshShell = WScript.CreateObject("WScript.Shell")


If WScript.Arguments.Count = 0 Then
ExecTime = "poweredon"
Else
ExecTime = WScript.Arguments(0)
End If

If ExecTime = "startup" Then
'startup: aspetta 1 minuto dal boot
WaitAtLeast(60)
End If

CheckRouterState(ExecTime)

Wlanstat = CheckWlanStat

If Wlanstat = "running" Then
'caso di wireless on

If (ExecTime = "startup" or ExecTime = "poweredon") Then
'startup o durante il lavoro: chiede ed eventualmente spegne

Msg = MsgBox("Lasciare attivato il Wireless?",4100,"Controllo WLan")

If Msg = 6 Then
Wscript.Quit(0)
Else
Wireless("off")
End If

'altrimenti significa che ExecTime = "shutdown", quindi lasciamo acceso
End If

ElseIf Wlanstat = "disabled" Then
'caso di wireless off

If ExecTime = "shutdown" Then
'in chiusura riaccende
Wireless("on")

ElseIf ExecTime = "startup" Then
'wireless spento all'accensione pc: avvisa di speghere il pc prima del router ed esce
Msg = WshShell.Popup("Il Wireless era disattivato. In chiusura ricordati che" & VbCrLf & "va spento prima il computer e poi il router",10,"Controllo WLan",4096)
Wscript.Quit(0)

Else
'altrimenti chiede ed eventualmente attiva
Msg = MsgBox("Attivare il Wireless?",4100,"Controllo WLan")

If Msg = 6 Then
Wireless("on")
End If

End If

ElseIf Wlanstat = "undefined" Then
'problemi
Msg = WshShell.Popup("Non riesco a controllare lo stato Wireless dell'apparecchio",10,"Controllo WLan",4096)

End If

Set WshShell = Nothing


Function CheckWlanStat
'restituisce stato wireless

For attempts = 1 to 3

BrowserIstance

BrowserRouterLogin

CheckWlanStat = BrowserWlanStatusResponse

Browser.Quit

If CheckWlanStat <> "undefined" Then Exit For

Next

End Function

Sub Wireless(byval switch)
'accende e spegne Wireless con macro su Internet explorer
'max tre tentativi

For attempts = 1 to 3

BrowserIstance

BrowserRouterLogin

Navigate "http://" & IP_DEL_ROUTER_ALICE & "/admin.cgi?active_page=9133"

If switch = "on" Then

Click "button", "Attiva"

Else

Click "button", "Configura Rete Wi-Fi"

Click "radio", "radio_interface_active_0"

Click "button", "Salva"

Click "button", "Avanti >"

End If

ResultWlanStat = BrowserWlanStatusResponse

Navigate "http://" & IP_DEL_ROUTER_ALICE & "/"

Click "img", "img33"

Browser.Quit

If (switch = "on" and ResultWlanStat = "running") or (switch = "off" and ResultWlanStat = "disabled") Then
Exit Sub
End If

Next

Msg = MsgBox("Il controllo del Wireless non è andato a buon fine",4096,"Controllo WLan")

End Sub

Sub BrowserIstance
'ritorna ie pronto, se startup istanzia e chiude ie n volte prima di tornare indietro

If ExecTime = "startup" Then
attempts = 2
Else
attempts = 1
End If

For i = 1 to attempts  

Set Browser = CreateObject("InternetExplorer.Application")
with Browser
.Visible = false
.ToolBar = false
.StatusBar = false
.Height = 400
.Width = 600
.Navigate "http://" & IP_DEL_ROUTER_ALICE & "/"
End with

BrowserPause

If i < attempts Then Browser.Quit

Next

End Sub

Sub BrowserRouterLogin
'entra nel router con Ie

Navigate "http://" & IP_DEL_ROUTER_ALICE & "/mainFrame.html"

Click "button", "Avanti >"

WritePassword

Click "button", "Accedi"

End Sub

Function BrowserWlanStatusResponse
'controlla wireless con browsing ie nel router

Navigate "http://" & IP_DEL_ROUTER_ALICE & "/admin.cgi?active_page=9133"

BrowserPause

For Each HTMLEle In Browser.Document.getElementsByTagName("td")

str = HTMLEle.InnerHtml

If str = "Abilitato" Then
BrowserWlanStatusResponse = "running"
Exit Function
ElseIf inStr (str, "Wi-Fi non è attiva") Then
BrowserWlanStatusResponse = "disabled"
Exit Function
End If

Next

BrowserWlanStatusResponse = "undefined"

End Function

Sub Click(byval EleType, byval EleValue)
'clicca oggetti di internet explorer

If EleType = "button" Then
TagName = "INPUT"
TagProperty = "VALUE"
ElseIf EleType = "img" Then
TagName = "IMG"
TagProperty = "NAME"
ElseIf EleType = "radio" Then
TagName = "INPUT"
TagProperty = "ID"
End If

BrowserPause

For Each HTMLEle In Browser.Document.getElementsByTagName( TagName )

str = lcase(HTMLEle.getAttribute( TagProperty ))

If str = lcase(EleValue) Then
HTMLEle.click
IEElementClick = "True"
BrowserPause
exit sub
End if
Next

End Sub

Sub WritePassword
'scrive la password nel form di alice in IE

BrowserPause
    
     For Each HTMLEle In Browser.Document.getElementsByTagName("INPUT")
             str = lcase(HTMLEle.getAttribute("name"))
 
             If Left(str, 8) = "password" Then
                 HTMLEle.setAttribute "value", PASSWORD_DEL_ROUTER_ALICE
                 IEValueChange = "True"
BrowserPause
                 exit sub
             End if
     Next
    
End Sub

Sub Navigate(byval url)
'naviga e aspetta che non For oIE to NOT be busy
    
BrowserPause
    Browser.Navigate url
BrowserPause

End sub

Sub BrowserPause
'aspetta che ie sia pronto

Do Until Browser.ReadyState = 4 and not Browser.Busy
    Loop  

End Sub

Sub WaitAtLeast( byVal LagSecs )
'guarda da quanto è acceso il pc ed eventualmente aspetta fino al numero di secondi dichiarato

Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_OperatingSystem", , 48 )

For Each objItem in colItems
UpTimeSecs  = DateDiff( "s", _
ParseDat( objItem.LastBootUpTime ), _
ParseDat( objItem.LocalDateTime ) )
Next

If UpTimeSecs < LagSecs Then
Wscript.sleep ( ( LagSecs - UpTimeSecs ) * 1000 )
End If

Set objWMIService = Nothing
Set colItems = Nothing

End Sub

Function ParseDat( ByVal strDate )
'restituisce la data da oggetti di sistema
'Grazie a Rob van der Woude
'http://www.robvanderwoude.com

strYear  = Left( strDate, 4 )
strMonth = Mid( strDate,  5, 2 )
strDay   = Mid( strDate,  7, 2 )
strDat   = strDay & "-" & strMonth & "-" & strYear
strHour  = Mid( strDate,  9, 2 ) - strTimeShift
strMins  = Mid( strDate, 11, 2 )
strTime  = strHour & ":" & strMins
ParseDat = strDat & " " & strTime

End Function

Function PingSite( myWebsite )
' This function checks if a website is running by sending an HTTP request.
' If the website is up, the function returns True, otherwise it returns False.
' Argument: myWebsite [string] in "www.domain.tld" format, without the
' "http://" prefix.
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com

Dim intStatus, objHTTP

Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

objHTTP.Open "GET", "http://" & myWebsite & "/", False
objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

On Error Resume Next

objHTTP.Send
intStatus = objHTTP.Status

On Error Goto 0

Set objHTTP = Nothing

If intStatus = 200 Then
PingSite = True
Else
PingSite = False
End If

End Function

Sub CheckRouterState(ExecTime)
'controlla se il router è funzionante ed eventualmente aspetta la sua operatività
'nel caso non sia funzionante e siamo in shutdown esce

If PingSite( IP_DEL_ROUTER_ALICE ) = False Then
If ExecTime = "shutdown" Then
Wscript.Quit(0)
Else
timeout = 0

Msg = WshShell.Popup("Attendo operatività del router per 3 minuti",5,"Controllo WLan",4096)

Do While PingSite( IP_DEL_ROUTER_ALICE ) = False and timeout < 180
WScript.sleep 1000
timeout = timeout + 1
Loop

If timeout = 180 Then Wscript.Quit(0)

ExecTime = "poweredon"

End If
End If

End Sub

Sub Debug (byval dvar)
Wscript.echo dvar
End Sub
« Ultima modifica: 03 Ottobre 2011, 20:50 da fiorenontaglio »