ALLELUJA ALLELUJA!!!!!
per la serie "sono un pollo" ...... il server telnet aspetta un Carriage Return per passare all'interprestazione dei comandi .....
quindi e' bastato aggiungere al comando inviato al telent (nel mio caso per esempio "uls") il carattere CR ovvero chr(10) ... poi inviarlo
Public Function MLTCommand(comando As String) As Boolean
hTim = New Timer As "Timer1"
hTim.Delay = 10000 '10 secondi di timeout
hTim.Enabled = True 'poi aspetto per il time out
If TcpConnection.Status = Net.Connected Then
Comando = comando [b]& Chr(10)[/b]
Write #TcpConnection, Comando, Len(Comando)
End If
Print "comando: " & Comando
hTim.Enabled = True 'poi aspetto per il time out per la risposta dal server
Do
Wait
Loop Until (Risposta <> "") Or (hTim.Enabled = False)
If hTim.Enabled = False Then
Return False
End If
Print Risposta
hTim.Stop
End
ora il probelma e' che la procedura:
Public Sub TcpConnection_read()
'****************************************
' When some data arrives from the remote
' part of the socket, "DataAvailable" event
' is raised
'****************************************
If TcpConnection.Status = Net.Connected Then
Read #TcpConnection, Risposta, Lof(TcpConnection)
Print Risposta
End If
End
mi ritorna una sola stringa, ma l'output del server puo' essere una serie di righe in serie.
Ovvero, questo e' quello che restituisce il server utilizzandolo via telnet/bash:
201 OK
U0 00 sdl_preview:384x288 1
e questo e' quello che restituisce la procedura di lettura sopra indicata:
201 OK
ho anche provato cosi':
Public Sub TcpConnection_read()
'****************************************
' When some data arrives from the remote
' part of the socket, "DataAvailable" event
' is raised
'****************************************
If TcpConnection.Status = Net.Connected Then
While Not Eof(TcpConnection)
Read #TcpConnection, Risposta, Lof(TcpConnection)
Print Risposta
Wend
Endif
End
ma sempre con scaris risultati ....
201 OK
ho anche provato cosi':
Chissà se provi con:
While True
....
....
Wend
Ponendo True, la condizione risulta sempre vera, generando virtualmente un ciclo infinito. Dal ciclo si uscirà soltanto quando non c'è più niente da leggere.
altro test .....
dopo aver definito cosi':
Private hTim As Timer 'timer per il timeout
Public Risposta As String 'e' la stringa che contiene la stringa di ritorno dal server MLT
Public Ritorno As New String[] 'e' il vettore di stringhe che immagazzinanao le righe ritornate dal server telent MLT
Public indice As Integer
chiamo cosi':
SendCommand("list u0") 'chiede al server cosa contiene la lista media dell'unita' u0
hTim.Delay = 2000 'aspetto un po' meno dei soliti 10 secondi (ora 2 sec)
hTim.Enabled = True 'aspetto per il time out per la risposta dal server
Do
Wait
Loop Until hTim.Enabled = False
Print Ritorno.Count
If (Ritorno(0) Like "*201 OK*") = True Then
'significa che il server ha riconosciuto il comando e mi ha ritornato la lista dei parametri nel vettore
hTim.Stop
For j = 0 To Ritorno.Count - 1
Print Ritorno(j) 'stampa le righe
Next
Else
'ho solo il time out e c'e' un problema
Print "NON riesco ad ottenere la lista dei media (TIME OUT)!" & gb.CrLf & Risposta & gb.crlf & "Contattare l'amministratore !!!!"
'send email to admin
Quit
Endif
questo e' il "comando"
Public Sub SendCommand(comando As String)
risposta = "" 'cancella la stringa di ritorno dalla lettura telnet
Ritorno.Clear 'cancella il vettore
indice = 0 'indice del vettore delle righe restituite dal server
If TcpConnection.Status = Net.Connected Then
Comando = comando & Chr(10)
Write #TcpConnection, Comando, Len(Comando)
End If
End
e questo il read dal socket:
Public Sub TcpConnection_read()
'****************************************
' When some data arrives from the remote
' part of the socket, "DataAvailable" event
' is raised
'****************************************
If TcpConnection.Status = Net.Connected Then
Read #TcpConnection, Risposta, Lof(TcpConnection)
Ritorno.Add(risposta)
End If
End
effettivamente l'array si riempie con 2 oggetti ma non riesco ad accedere al singolo elemento:
OTVA deamon for channel: Tele Galileo
DB_server: 192.168.1.91:3306
DB_account: OTVA_user:OTVA_password
refresh frequency: 30 minutes
Melted server: localhost:5250
select * from MediaPlaylist where channel = 'Tele Galileo' and data = '10/23/2013' order by start_time
ci sono 0 media in lista
select * from SpotPlaylist where channel = 'Tele Galileo' and date = '10/23/2013' order by time
ci sono 0 spot in lista
tentativo di connessione ...
connessione al server melted RIUSCITA!
CONNESSO
2
MMain.GetMeltedServerStatus.278: #9: Not a function
1: MMain.GetMeltedServerStatus.278
2: MMain.Main.141
.... penso che l'errore sia qui' :
If (Ritorno(0) Like "*201 OK*") = True Then
ma non so cosa intenda :-(
.... penso che l'errore sia qui' :
If (Ritorno(0) Like "*201 OK*") = True Then
ma non so cosa intenda :-(
Essendo "Ritorno" un vettore di tipo String[] e non una funzione, quella riga andrebbe scritta così:
If (Ritorno[0] Like "*201 OK*") = True Then
la quale significherà: se la stringa, presente nel primo elemento della variabile vettoriale "Ritorno", contiene la riga "201 OK", allora......