2010-11-25 30 views
6

Hola Necesito publicar una solicitud a la página aspx dentro de la línea de comando dos ... ¿Cómo puedo hacer eso?cómo publicar una solicitud HTTP desde la línea de comando

+0

C#? vb? Se puede hacer – hunter

+0

Cuando dices publicar una solicitud http, ¿te refieres a un HTTP POST, o simplemente quieres decir que quieres una página web como lo haría cualquier otro navegador (HTTP GET)? –

Respuesta

6

Crear un archivo .vbs que contiene:

' Set your settings 
    strFileURL = "http://localhost/index.aspx" 
    strHDLocation = "stream.temp" 

' Fetch the file 
    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP") 

    objXMLHTTP.open "GET", strFileURL, false 
    objXMLHTTP.send() 

If objXMLHTTP.Status = 200 Then 
Set objADOStream = CreateObject("ADODB.Stream") 
objADOStream.Open 
objADOStream.Type = 1 'adTypeBinary 

objADOStream.Write objXMLHTTP.ResponseBody 
objADOStream.Position = 0 'Set the stream position to the start 

Set objFSO = Createobject("Scripting.FileSystemObject") 
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation 

objADOStream.SaveToFile strHDLocation 
objADOStream.Close 
Set objADOStream = Nothing 
End if 

Set objXMLHTTP = Nothing 

' Delete the temp file 
objFSO.DeleteFile strHDLocation 

Set objFSO = Nothing 

luego ejecutar usando:

cscript.exe scriptname.vbs 
18

telnet en el puerto 80

Por ejemplo:

telnet www.your-server.com/pageToTest.aspx 80 

continuación, escriba GET

+0

obtengo 'C: \ Windows \ system32> telnet 'telnet' no se reconoce como un comando interno o externo, programa operable o archivo por lotes' – CodyBugstein

+1

Puede activar el paquete de telenet escribiendo estos dos comandos, luego después reinicia tu computadora y todo estará bien!
pkgmgr/iu: TelnetClient
pkgmgr/iu: TelnetServer –

+0

Más información: http://www.esqsoft.com/examples/troubleshooting-http-using-telnet.htm – Ring

2

que he tenido algo de buena suerte con el enrollamiento de http://curl.haxx.se/ para replicar el envío de JSON a un servicio web. Quizás esto también podría ayudarte.

5

Esto se puede hacer usando wget.

+1

¿Podría explicar con un ejemplo? –

1

Telnet es realmente para la conexión a un servidor telnet remoto. De hecho, (servidor de telnet) no está presente en Windows 10, solo el cliente. Es mejor que utilice PowerShell. Aquí está accediendo a un ejemplo de servicio OData: http://hodentekhelp.blogspot.com/2014/11/can-you-access-odata-with-powershell.html

comentario También en este tema: https://social.technet.microsoft.com/Forums/en-US/035062dd-5052-4abe-bd9a-8714f4184806/there-is-no-telnet-server-in-windows-10-what-is-the-purpose-of-telnet-client?forum=win10itprogeneral

Cuestiones relacionadas