Hacer telnet

View: New views
5 Messages — Rating Filter:   Alert me  

Hacer telnet

by Manuel Verde Salmeron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hola.
Estoy intentando hacer telnet a un servidor. Este servidor esta suministrando datos en formato plano.
Para la probar mando el resultado a un fichero
Lo hago mediante:
SHELL "gnome-terminal|telnet datos.org 8000 >nuevo.txt"
El puerto para hacer el telnet es el 8000, esto funciona.
El problema esta en que el servidor me pide un nombre.
Como puedo:
  1. Comprobar que la conexion se ha realizado.
  2. Como indicarle al servidor el nombre?.
gracias por la ayuda
Un saludo.
Manuel.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es

Re: Hacer telnet

by Pumarfa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

El 18 de agosto de 2009 19:55, Manuel Verde
Salmeron<ea7tbravo@...> escribió:

> Hola.
> Estoy intentando hacer telnet a un servidor. Este servidor esta
> suministrando datos en formato plano.
> Para la probar mando el resultado a un fichero
> Lo hago mediante:
> SHELL "gnome-terminal|telnet datos.org 8000 >nuevo.txt"
> El puerto para hacer el telnet es el 8000, esto funciona.
> El problema esta en que el servidor me pide un nombre.
> Como puedo:
>
> Comprobar que la conexion se ha realizado.
> Como indicarle al servidor el nombre?.
>

En éste caso, donde se ejecuta comandos de la SHEL, recomiendo primero
hacerse con los datos necesarios para la conexión (Usario, Passwdord,
Host, puerto y protocolo de conexión)

Y en segundo lugar, al se un proceso donde se requiere varios pasos
(Como le Telnet) usar script basados en otros lenguajes como AWN o
Spect, que permiten los script iterativos de forma más simples que el
típico BASH.

> gracias por la ayuda
> Un saludo.
> Manuel.
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gambas-user-es mailing list
> Gambas-user-es@...
> https://lists.sourceforge.net/lists/listinfo/gambas-user-es
>
>



--
"El software libre es el nuevo continente que hemos construido en el
ciberespacio, y por ser virtual tiene campo para todos".
-R.Stallman.
"Hoy en día llaman libertad de expresión a la libertad que tienes de
hablar sin que nadie te escuche" - David Bravo Bueno

-- Por favor: Piense bien antes de imprimir esto, el planeta se lo agradecerá.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es

Re: Hacer telnet

by Jesus Guardon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hola Manuel

¿Por qué usar la shell de linux si Gambas2 dispone de sus propios
métodos? Echa un vistazo a éste código, extraído de mi programa dfhlog a
ver si es lo que necesitas:

'***********************CLUSTER******************************

PUBLIC SUB btnConn_Click()
    'conectar al cluster
    DIM sServer AS String[]
    DIM sHost, sPort AS String
    DIM S AS String = ini["Telnet/Server"]
    IF S THEN
        tabLC.Index = 1
        sServer = Split(S, ":")
        sHost = sServer[0]
        sPort = sServer[1]  
        IF btnConn.Value = TRUE THEN      
            IF sktCluster.Status <> Net.Connected THEN
                sktCluster.Host = sHost
                sktCluster.Port = sPort
                WAIT 0.1
                TRY sktCluster.Connect()
            ENDIF
        ELSE        
            IF sktCluster.Status = Net.Connected THEN
                sktCluster.Close()              
            ENDIF
        ENDIF
    ELSE
        STOP EVENT
        btnConn.Value = FALSE
        Message.Info(("Not yet configured any Cluster server in your settings."))      
    ENDIF
   
    CATCH    
        Message.Error(("Error in btnConn_Click\n") & Error.Text & "\n" & Error.Where)
END

PUBLIC SUB sktCluster_Ready()  
    'Inicializo un fichero para luego escribir en él
    DIM F AS File
    DIM S, fic AS String      
    fic = User.Home &/ ".xplanet/markers/dx"    
    F = OPEN fic FOR WRITE CREATE        
    CLOSE #F  
    txtClx.SetFocus()
END

PUBLIC SUB sktCluster_Read()  
    IF sktCluster.Status = Net.Connected THEN    
        LINE INPUT #sktCluster, L
        IF ini["Telnet/Autologin"] = TRUE THEN
            'aquí está lo que buscas, espero a recibir
            'la cadena que me interesa, para responder
            'con otra cadena
            IF InStr(L, "login:") > 0 THEN WRITE #sktCluster, strippedCall() & "\r\n", Len(strippedCall()) + 2
        ENDIF
        'aquí ya le das el tratamiento necesario
        'a cada línea recibida
        filterLine(L)
    ENDIF
END


Saludos

Jesús, EA7DFH


Manuel Verde Salmeron wrote:

> Hola.
> Estoy intentando hacer telnet a un servidor. Este servidor esta
> suministrando datos en formato plano.
> Para la probar mando el resultado a un fichero
> Lo hago mediante:
> SHELL "gnome-terminal|telnet datos.org <http://datos.org> 8000 >nuevo.txt"
> El puerto para hacer el telnet es el 8000, esto funciona.
> El problema esta en que el servidor me pide un nombre.
> Como puedo:
>
>    1. Comprobar que la conexion se ha realizado.
>    2. Como indicarle al servidor el nombre?.
>
> gracias por la ayuda
> Un saludo.
> Manuel.
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gambas-user-es mailing list
> Gambas-user-es@...
> https://lists.sourceforge.net/lists/listinfo/gambas-user-es
>  


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es

Re: Hacer telnet

by Pumarfa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Totalmente cierto...

Mil disculpas. Pero es que soy muy verde en Gambas... (Y hace mucho
hago automatización con script de Bash)

La solución planteada por Jesus es de lejos la mejor alternativa.
Aprovechando los componentes Net de Gambas, sin la necesidad de
interactuar con scripting de la consola.

El 19 de agosto de 2009 06:28, Jesus Guardon<jguardon@...> escribió:

> Hola Manuel
>
> ¿Por qué usar la shell de linux si Gambas2 dispone de sus propios
> métodos? Echa un vistazo a éste código, extraído de mi programa dfhlog a
> ver si es lo que necesitas:
>
> '***********************CLUSTER******************************
>
> PUBLIC SUB btnConn_Click()
>    'conectar al cluster
>    DIM sServer AS String[]
>    DIM sHost, sPort AS String
>    DIM S AS String = ini["Telnet/Server"]
>    IF S THEN
>        tabLC.Index = 1
>        sServer = Split(S, ":")
>        sHost = sServer[0]
>        sPort = sServer[1]
>        IF btnConn.Value = TRUE THEN
>            IF sktCluster.Status <> Net.Connected THEN
>                sktCluster.Host = sHost
>                sktCluster.Port = sPort
>                WAIT 0.1
>                TRY sktCluster.Connect()
>            ENDIF
>        ELSE
>            IF sktCluster.Status = Net.Connected THEN
>                sktCluster.Close()
>            ENDIF
>        ENDIF
>    ELSE
>        STOP EVENT
>        btnConn.Value = FALSE
>        Message.Info(("Not yet configured any Cluster server in your settings."))
>    ENDIF
>
>    CATCH
>        Message.Error(("Error in btnConn_Click\n") & Error.Text & "\n" & Error.Where)
> END
>
> PUBLIC SUB sktCluster_Ready()
>    'Inicializo un fichero para luego escribir en él
>    DIM F AS File
>    DIM S, fic AS String
>    fic = User.Home &/ ".xplanet/markers/dx"
>    F = OPEN fic FOR WRITE CREATE
>    CLOSE #F
>    txtClx.SetFocus()
> END
>
> PUBLIC SUB sktCluster_Read()
>    IF sktCluster.Status = Net.Connected THEN
>        LINE INPUT #sktCluster, L
>        IF ini["Telnet/Autologin"] = TRUE THEN
>            'aquí está lo que buscas, espero a recibir
>            'la cadena que me interesa, para responder
>            'con otra cadena
>            IF InStr(L, "login:") > 0 THEN WRITE #sktCluster, strippedCall() & "\r\n", Len(strippedCall()) + 2
>        ENDIF
>        'aquí ya le das el tratamiento necesario
>        'a cada línea recibida
>        filterLine(L)
>    ENDIF
> END
>
>
> Saludos
>
> Jesús, EA7DFH
>
>
> Manuel Verde Salmeron wrote:
>> Hola.
>> Estoy intentando hacer telnet a un servidor. Este servidor esta
>> suministrando datos en formato plano.
>> Para la probar mando el resultado a un fichero
>> Lo hago mediante:
>> SHELL "gnome-terminal|telnet datos.org <http://datos.org> 8000 >nuevo.txt"
>> El puerto para hacer el telnet es el 8000, esto funciona.
>> El problema esta en que el servidor me pide un nombre.
>> Como puedo:
>>
>>    1. Comprobar que la conexion se ha realizado.
>>    2. Como indicarle al servidor el nombre?.
>>
>> gracias por la ayuda
>> Un saludo.
>> Manuel.
>>
>> ------------------------------------------------------------------------
>>
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
>> trial. Simplify your report design, integration and deployment - and focus on
>> what you do best, core application coding. Discover what's new with
>> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Gambas-user-es mailing list
>> Gambas-user-es@...
>> https://lists.sourceforge.net/lists/listinfo/gambas-user-es
>>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Gambas-user-es mailing list
> Gambas-user-es@...
> https://lists.sourceforge.net/lists/listinfo/gambas-user-es
>



--
"El software libre es el nuevo continente que hemos construido en el
ciberespacio, y por ser virtual tiene campo para todos".
-R.Stallman.
"Hoy en día llaman libertad de expresión a la libertad que tienes de
hablar sin que nadie te escuche" - David Bravo Bueno

-- Por favor: Piense bien antes de imprimir esto, el planeta se lo agradecerá.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es

Re: Hacer telnet

by Manuel Verde Salmeron :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hola Jesus
Gracias por tu respuesta.
Esto es lo que necesito.
Saludos.
Manuel Verde

El 19 de agosto de 2009 11:28, Jesus Guardon <jguardon@...> escribió:
Hola Manuel

¿Por qué usar la shell de linux si Gambas2 dispone de sus propios
métodos? Echa un vistazo a éste código, extraído de mi programa dfhlog a
ver si es lo que necesitas:

'***********************CLUSTER******************************

PUBLIC SUB btnConn_Click()
   'conectar al cluster
   DIM sServer AS String[]
   DIM sHost, sPort AS String
   DIM S AS String = ini["Telnet/Server"]
   IF S THEN
       tabLC.Index = 1
       sServer = Split(S, ":")
       sHost = sServer[0]
       sPort = sServer[1]
       IF btnConn.Value = TRUE THEN
           IF sktCluster.Status <> Net.Connected THEN
               sktCluster.Host = sHost
               sktCluster.Port = sPort
               WAIT 0.1
               TRY sktCluster.Connect()
           ENDIF
       ELSE
           IF sktCluster.Status = Net.Connected THEN
               sktCluster.Close()
           ENDIF
       ENDIF
   ELSE
       STOP EVENT
       btnConn.Value = FALSE
       Message.Info(("Not yet configured any Cluster server in your settings."))
   ENDIF

   CATCH
       Message.Error(("Error in btnConn_Click\n") & Error.Text & "\n" & Error.Where)
END

PUBLIC SUB sktCluster_Ready()
   'Inicializo un fichero para luego escribir en él
   DIM F AS File
   DIM S, fic AS String
   fic = User.Home &/ ".xplanet/markers/dx"
   F = OPEN fic FOR WRITE CREATE
   CLOSE #F
   txtClx.SetFocus()
END

PUBLIC SUB sktCluster_Read()
   IF sktCluster.Status = Net.Connected THEN
       LINE INPUT #sktCluster, L
       IF ini["Telnet/Autologin"] = TRUE THEN
           'aquí está lo que buscas, espero a recibir
           'la cadena que me interesa, para responder
           'con otra cadena
           IF InStr(L, "login:") > 0 THEN WRITE #sktCluster, strippedCall() & "\r\n", Len(strippedCall()) + 2
       ENDIF
       'aquí ya le das el tratamiento necesario
       'a cada línea recibida
       filterLine(L)
   ENDIF
END


Saludos

Jesús, EA7DFH


Manuel Verde Salmeron wrote:
> Hola.
> Estoy intentando hacer telnet a un servidor. Este servidor esta
> suministrando datos en formato plano.
> Para la probar mando el resultado a un fichero
> Lo hago mediante:
> SHELL "gnome-terminal|telnet datos.org <http://datos.org> 8000 >nuevo.txt"
> El puerto para hacer el telnet es el 8000, esto funciona.
> El problema esta en que el servidor me pide un nombre.
> Como puedo:
>
>    1. Comprobar que la conexion se ha realizado.
>    2. Como indicarle al servidor el nombre?.
>
> gracias por la ayuda
> Un saludo.
> Manuel.
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gambas-user-es mailing list
> Gambas-user-es@...
> https://lists.sourceforge.net/lists/listinfo/gambas-user-es
>


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user-es mailing list
Gambas-user-es@...
https://lists.sourceforge.net/lists/listinfo/gambas-user-es