escrevendo a resposta do netcat no arquivo de texto

0

Eu tenho um arquivo de script que envia um pedido de sabão para o servidor remoto e fornece a resposta no terminal. No entanto, eu quero essa resposta do terminal para o arquivo de texto para que eu possa usá-lo mais tarde.

Eu tenho uma solicitação de netcat como:

#!/bin/sh

HOST=192.168.2.220
PORT=8080

nc  $HOST $PORT 0 << __EOF__
POST / HTTP/1.1
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Header/>
 <SOAP-ENV:Body>
  <adm:serverInfo xmlns:adm="http://log4ensics.com/2010/AdminInterface"/>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
__EOF__ 

Eu tenho a resposta no terminal como

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fb="http://log4ensics.com/2010/AdminInterface/FileBinding" xmlns:mb="http://log4ensics.com/2010/AdminInterface/ModuleBinding" xmlns:rb="http://log4ensics.com/2010/AdminInterface/RouteBinding" xmlns:sb="http://log4ensics.com/2010/AdminInterface/ServerBinding" xmlns:ns="http://log4ensics.com/2010/AdminInterface"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><ns:serverInfoReply><started>1444714509692781</started><load>0.126918644</load><pid>948</pid><mem>14745600</mem><modules><module-name>eventlog</module-name><evt-recvd>249668</evt-recvd><evt-drop>0</evt-drop><evt-fwd>249668</evt-fwd><queuesize>0</queuesize><status>3</status><module-type>1</module-type><module>im_msvistalog</module></modules><modules><module-name>agentlogging</module-name><evt-recvd>1</evt-recvd><evt-drop>0</evt-drop><evt-fwd>1</evt-fwd><queuesize>0</queuesize><status>2</status><module-type>1</module-type><module>im_internal</module></modules><modules><module-name>logcontents</module-name><evt-recvd>249668</evt-recvd><evt-drop>0</evt-drop><evt-fwd>249668</evt-fwd><queuesize>0</queuesize><status>3</status><module-type>3</module-type><module>om_tcp</module></modules><modules><module-name>agentlog</module-name><evt-recvd>0</evt-recvd><evt-drop>0</evt-drop><evt-fwd>0</evt-fwd><queuesize>157</queuesize><status>1</status><module-type>3</module-type><module>om_tcp</module></modules><version>2.9.1427</version><os>Windows</os><systeminfo>Windows Server 2012, 2 CPU(s), 4.0Gb memory</systeminfo><hostname>ADServer</hostname><servertime>1444716606837528</servertime></ns:serverInfoReply></SOAP-ENV:Body></SOAP-ENV:Envelope>

Como posso escrever essa resposta para o arquivo de texto?

    
por laxmi 13.10.2015 / 08:16

1 resposta

0

Veja Redirecionar a saída para o arquivo :

#!/bin/sh

HOST=192.168.2.220
PORT=8080

nc  $HOST $PORT 0 << __EOF__ > output.txt
POST / HTTP/1.1
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP-ENV:Header/>
 <SOAP-ENV:Body>
  <adm:serverInfo xmlns:adm="http://log4ensics.com/2010/AdminInterface"/>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
__EOF__ 
    
por 13.10.2015 / 08:26

Tags