How to print the lines between the pattern using awk/grep/sed?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print the lines between the pattern using awk/grep/sed?
# 1  
Old 06-22-2012
How to print the lines between the pattern using awk/grep/sed?

Hi,
I need a help to search a pattern and print the multiple lines between them.

Input file:
Code:
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=NAS}{enddate=2012-07-08T00:00:00}{stdLinkCode=HBS_SANDALS}{hotelVersion=}{roomCode=XLO}{hotelConfID=}{linkConfID=SRBeOGu4c6}{ratePlanCode=LUXINC4}{hotelCode=SRB}{mealPlanCode=AI}{channelType=A}{startDate=2012-07-04T00:00:00}{linkVersion=}
    {Pax}{firstName=KUNAL RATA}{age=25}{lastName=OKHANDIAR}
    {Pax}{firstName=ASHITA}{age=25}{lastName=SINHA}

Tue May 29 12:30:33 EDT 2012:threadThread-72544:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): 
Tue May 29 12:30:33 EDT 2012:threadThread-72466:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run():milliseconds.
Tue May 29 12:30:33 EDT 2012:threadThread-72546:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): 
Tue May 29 12:30:33 EDT 2012:threadThread-72547:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): 
Tue May 29 12:30:33 EDT 2012:threadThread-72384:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): 
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=1}{sessionID=99}
  {Error}{destCode=SRB}{errorCode=1008}{hotelCode=NAS}{errorMessage=The system received a communication error from link HBS_SANDALS.  Please try your request again.}

Output i need from this file:

Result1:
Code:
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
{Cancellation}{destCode=NAS}{enddate=2012-07-08T00:00:00}{stdLinkCode=HBS_SANDALS}{hotelVersion=}{roomCode=XLO}{hotelConfID=}{linkConfID=SRBeOGu4c6}{ratePlanCode=LUXINC4}{hotelCode=SRB}{mealPlanCode=AI}{channelType=A}{startDate=2012-07-04T00:00:00}{linkVersion=}
    {Pax}{firstName=KUNAL RATA}{age=25}{lastName=OKHANDIAR}
    {Pax}{firstName=ASHITA}{age=25}{lastName=SINHA}

Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=1}{sessionID=99}
  {Error}{destCode=SRB}{errorCode=1008}{hotelCode=NAS}{errorMessage=The system received a communication error from link HBS_SANDALS.  Please try your request again.}

Result2:
Code:
Tue May 29 12:30:04 EDT 2012:threadWebContainer : 356:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=NAS}{enddate=2012-07-30T00:00:00}{stdLinkCode=HBS_KERZNER}{hotelVersion=}{roomCode=UNT}{hotelConfID=1120136}{linkConfID=KP5rhsgKpZ}{ratePlanCode=C2BAR20}{hotelCode=COV}{mealPlanCode=EP}{channelType=A}{startDate=2012-07-26T00:00:00}{linkVersion=}
    {Pax}{firstName=RICHARD}{age=25}{lastName=MAYS}
    {Pax}{firstName=SUPHA}{age=25}{lastName=VANDIVER}
    
Tue May 29 12:30:04 EDT 2012:threadWebContainer : 356:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=1}{sessionID=99}
  {Error}{destCode=COV}{errorCode=1008}{hotelCode=NAS}{errorMessage=The system received a communication error from link HBS_KERZNER.  Please try your request again.}

I tried this command but it didn't worked well.
Code:
awk '/errorCode=1008/ && /requestType=hotelCancelReservation/' RS="" Filename

.

My requiremment is:
search in the file for requestType=hotelCancelReservation and if the response of this request is "errorCode=1008" then print all the lines between them.

---------- Post updated at 07:27 PM ---------- Previous update was at 07:03 PM ----------

sorry Input file is below one:
Code:
hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=NAP}{enddate=2012-08-24T00:00:00}{stdLinkCode=GTA}{hotelVersion=}{roomCode=STD}{hotelConfID=XX7F289756}{linkConfID=14009209}{ratePlanCode=BASE}{hotelCode=OG1}{mealPlanCode=BP}{channelType=A}{startDate=2012-08-23T00:00:00}{linkVersion=}

Tue May 29 12:00:26 EDT 2012:threadThread-63057:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:00:27 EDT 2012:threadThread-63057:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [1504] milliseconds.
Tue May 29 12:00:27 EDT 2012:threadThread-62953:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message [<?xml version="1.0" encoding="UTF-8" ?><Response ResponseReference="REF_P_028_841-4394-709504397258346" ResponseSequence="1"><ResponseDetails Language="en"><BookingResponse><BookingReferences><BookingReference ReferenceSource="client"><![CDATA[E54JO4YUHGS81P4VIUYQQFWUY]]></BookingReference><BookingReference ReferenceSource="agent"><![CDATA[502375]]></BookingReference><BookingReference ReferenceSource="api"><![CDATA[14009209]]></BookingReference></BookingReferences><BookingCreationDate>2012-05-23</BookingCreationDate><BookingDepartureDate>2012-08-23</BookingDepartureDate><BookingName><![CDATA[ANTHONY M PAOLUCCI]]></BookingName><BookingPrice Currency="EUR" Gross=".00" Commission=".00" Nett=".00"></BookingPrice><BookingStatus Code="X "><![CDATA[Cancelled]]></BookingStatus><PaxNames><PaxName PaxId="1"><![CDATA[ANTHONY M PAOLUCCI]]></PaxName><PaxName PaxId="2"><![CDATA[JENNIFER CHON]]></PaxName></PaxNames><BookingItems><BookingItem ItemType="hotel"><ItemReference>1</ItemReference><ItemCity Code="NAP"><![CDATA[Naples]]></ItemCity><Item Code="ORI"><![CDATA[GRAND HOTEL ORIENTE]]></Item><ItemPrice Currency="EUR" Gross="69.50" Commission=".00" Nett="69.50"></ItemPrice><ItemStatus Code="X "><![CDATA[Cancelled]]></ItemStatus><ItemConfirmationReference>XX7F289756</ItemConfirmationReference><EssentialInformation><Information><Text><![CDATA[Please be aware that a city accommodation tax may be        applicable in this destination, payable by cash by the guestat the hotel]]></Text><DateRange><FromDate>2012-05-18</FromDate><ToDate>9999-12-31</ToDate></DateRange></Information></EssentialInformation><HotelItem><PeriodOfStay><CheckInDate>2012-08-23</CheckInDate><CheckOutDate>2012-08-24</CheckOutDate></PeriodOfStay><HotelRooms><HotelRoom Code="TB"><PaxIds><PaxId>1</PaxId><PaxId>2</PaxId></PaxIds></HotelRoom></HotelRooms><Meals><Basis Code="B"><![CDATA[Breakfast]]></Basis><Breakfast Code="F"><![CDATA[Full]]></Breakfast></Meals></HotelItem></BookingItem></BookingItems></BookingResponse></ResponseDetails></Response>] from [] in [24814] milliseconds.
Tue May 29 12:00:27 EDT 2012:threadWebContainer : 310:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=0}{sessionID=99}
  {Confirmation}{origLinkConfID=14009209}{hotelConfId=C$E54JO4YUHGS81P4VIUYQQFWUY}{linkConfID=14009209}{origHotelConfID=XX7F289756}{linkVersion=0}
  
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
{Cancellation}{destCode=NAS}{enddate=2012-07-08T00:00:00}{stdLinkCode=HBS_SANDALS}{hotelVersion=}{roomCode=XLO}{hotelConfID=}{linkConfID=SRBeOGu4c6}{ratePlanCode=LUXINC4}{hotelCode=SRB}{mealPlanCode=AI}{channelType=A}{startDate=2012-07-04T00:00:00}{linkVersion=}
    {Pax}{firstName=KUNAL RATA}{age=25}{lastName=OKHANDIAR}
    {Pax}{firstName=ASHITA}{age=25}{lastName=SINHA}

Tue May 29 12:30:33 EDT 2012:threadThread-72544:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:30:33 EDT 2012:threadThread-72466:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [11049] milliseconds.
Tue May 29 12:30:33 EDT 2012:threadThread-72546:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:30:33 EDT 2012:threadThread-72547:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:30:33 EDT 2012:threadThread-72384:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [15698] milliseconds.
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=1}{sessionID=99}
  {Error}{destCode=SRB}{errorCode=1008}{hotelCode=NAS}{errorMessage=The system received a communication error from link HBS_SANDALS.  Please try your request again.}

Tue May 29 12:00:28 EDT 2012:threadWebContainer : 301:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=QLJ}{enddate=2012-08-20T00:00:00}{stdLinkCode=GTA}{hotelVersion=}{roomCode=STD}{hotelConfID=XX7F289317}{linkConfID=14000387}{ratePlanCode=BASE}{hotelCode=DR1}{mealPlanCode=BP}{channelType=A}{startDate=2012-08-18T00:00:00}{linkVersion=}

Tue May 29 12:00:46 EDT 2012:threadThread-63202:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [1348] milliseconds.
Tue May 29 12:00:46 EDT 2012:threadThread-63067:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message [<?xml version="1.0" encoding="UTF-8" ?><Response ResponseReference="REF_P_028_841-4395-671734297280654" ResponseSequence="1"><ResponseDetails Language="en"><BookingResponse><BookingReferences><BookingReference ReferenceSource="client"><![CDATA[AT1TMJ0WD0KT09HL14PA9Y3WJ]]></BookingReference><BookingReference ReferenceSource="agent"><![CDATA[502375]]></BookingReference><BookingReference ReferenceSource="api"><![CDATA[14000387]]></BookingReference></BookingReferences><BookingCreationDate>2012-05-21</BookingCreationDate><BookingDepartureDate>2012-08-18</BookingDepartureDate><BookingName><![CDATA[ANTHONY M PAOLUCCI]]></BookingName><BookingPrice Currency="CHF" Gross=".00" Commission=".00" Nett=".00"></BookingPrice><BookingStatus Code="X "><![CDATA[Cancelled]]></BookingStatus><PaxNames><PaxName PaxId="1"><![CDATA[ANTHONY M PAOLUCCI]]></PaxName><PaxName PaxId="2"><![CDATA[JENNIFER CHON]]></PaxName></PaxNames><BookingItems><BookingItem ItemType="hotel"><ItemReference>1</ItemReference><ItemCity Code="LUCE"><![CDATA[Lucerne]]></ItemCity><Item Code="DRE"><![CDATA[DREI KONIGE]]></Item><ItemPrice Currency="CHF" Gross="364.00" Commission=".00" Nett="364.00"></ItemPrice><ItemStatus Code="X "><![CDATA[Cancelled]]></ItemStatus><ItemConfirmationReference>XX7F289317</ItemConfirmationReference><HotelItem><PeriodOfStay><CheckInDate>2012-08-18</CheckInDate><CheckOutDate>2012-08-20</CheckOutDate></PeriodOfStay><HotelRooms><HotelRoom Code="TB"><PaxIds><PaxId>1</PaxId><PaxId>2</PaxId></PaxIds></HotelRoom></HotelRooms><Meals><Basis Code="B"><![CDATA[Breakfast]]></Basis><Breakfast Code="F"><![CDATA[Full]]></Breakfast></Meals></HotelItem></BookingItem></BookingItems></BookingResponse></ResponseDetails></Response>] from [] in [18679] milliseconds.
Tue May 29 12:00:46 EDT 2012:threadWebContainer : 301:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=0}{sessionID=99}
  {Confirmation}{origLinkConfID=14000387}{hotelConfId=C$AT1TMJ0WD0KT09HL14PA9Y3WJ}{linkConfID=14000387}{origHotelConfID=XX7F289317}{linkVersion=0}

Tue May 29 12:00:47 EDT 2012:threadWebContainer : 325:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=PLS}{enddate=2012-09-01T00:00:00}{stdLinkCode=HBS_SANDALS}{hotelVersion=}{roomCode=HC2}{hotelConfID=6532516}{linkConfID=BTCNrbTnp8}{ratePlanCode=LUXINC7}{hotelCode=BTC}{mealPlanCode=AI}{channelType=A}{startDate=2012-08-25T00:00:00}{linkVersion=}
    {Pax}{firstName=ROBERT}{age=25}{lastName=BLOUNT}
    {Pax}{firstName=KELLI}{age=25}{lastName=BLOUNT}

Tue May 29 12:00:47 EDT 2012:threadThread-63215:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message [<?xml version="1.0" encoding="UTF-8"?>
<HobooTransaction CmdId="249477474317572987270993201322324779191" Version="3.0" standBy="false" ErrorHandlingLevel="Transaction"><AccountInfo Password="hoboo" Username="travimp" Type="Property" AccountId="37925"/><AccountInfo Password="hoboo" Username="travimp" Type="Channel" AccountId="travimp2"/><ReservationCancellationList><ReservationCancellation CmdId="277582036873456976243483307806026318047" IdDc="BTCNrbTnp8" IdHoboo="BTCNrbTnp8"/></ReservationCancellationList></HobooTransaction>] to [].
Tue May 29 12:00:49 EDT 2012:threadThread-63215:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message [<HobooResult Version="3.0" CompleteRollback="false" CmdId="249477474317572987270993201322324779191" ExecutionCode="0" ExecutionMessage="Success!"><ReservationConfirmationList AccountId="37925"><Confirmation CmdId="277582036873456976243483307806026318047" IdPms="6532516" VersionPms="0" IdHoboo="BTCNrbTnp8" VersionHoboo="0" IdDc="362050/4297327939196" VersionDc="0" /></ReservationConfirmationList></HobooResult>] from [] in [1581] milliseconds.
Tue May 29 12:00:49 EDT 2012:threadWebContainer : 325:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=0}{sessionID=99}
  {Confirmation}{origLinkConfID=BTCNrbTnp8}{linkConfID=BTCNrbTnp8}{origHotelConfID=6532516}{linkVersion=0}

Tue May 29 12:00:49 EDT 2012:threadWebContainer : 310:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=ANU}{enddate=2013-02-24T00:00:00}{stdLinkCode=HBS_SANDALS}{hotelVersion=}{roomCode=OHR}{hotelConfID=6658027}{linkConfID=SATybIA0vG}{ratePlanCode=LUXINC5}{hotelCode=SAR}{mealPlanCode=AI}{channelType=A}{startDate=2013-02-19T00:00:00}{linkVersion=}
    {Pax}{firstName=SAMUEL ALL}{age=25}{lastName=SLINGLUFF}
    {Pax}{firstName=AMY LOUISE}{age=25}{lastName=SLINGLUFF}

Tue May 29 12:00:49 EDT 2012:threadThread-63221:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:00:50 EDT 2012:threadThread-63217:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message [<HobooResult Version="3.0" CompleteRollback="false" CmdId="313213998787882915905948531327337631713" ExecutionCode="0" ExecutionMessage="Success!"><ReservationConfirmationList AccountId="37954"><Confirmation CmdId="94476258899114850995703850486122983947" IdPms="6658027" VersionPms="0" IdHoboo="SATybIA0vG" VersionHoboo="0" IdDc="461109/0812420865454" VersionDc="0" /></ReservationConfirmationList></HobooResult>] from [] in [435] milliseconds.
Tue May 29 12:00:50 EDT 2012:threadWebContainer : 310:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=0}{sessionID=99}
  {Confirmation}{origLinkConfID=SATybIA0vG}{linkConfID=SATybIA0vG}{origHotelConfID=6658027}{linkVersion=0}

Tue May 29 12:00:50 EDT 2012:threadThread-63221:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [619] milliseconds.
Tue May 29 12:00:51 EDT 2012:threadWebContainer : 325:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=BRN}{enddate=2012-08-21T00:00:00}{stdLinkCode=GTA}{hotelVersion=}{roomCode=STD}{hotelConfID=XX7F289323}{linkConfID=14000410}{ratePlanCode=BASE}{hotelCode=VJ1}{mealPlanCode=BP}{channelType=A}{startDate=2012-08-20T00:00:00}{linkVersion=}

Tue May 29 12:01:06 EDT 2012:threadThread-63274:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63275:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63256:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [371] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63278:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63277:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63280:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63281:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Sent message to [].
Tue May 29 12:01:06 EDT 2012:threadThread-63275:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [77] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63278:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [72] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63250:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [459] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63281:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [93] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63265:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [549] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63274:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [316] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63277:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [315] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63262:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [738] milliseconds.
Tue May 29 12:01:06 EDT 2012:threadThread-63257:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message from [] in [846] milliseconds.
Tue May 29 12:01:07 EDT 2012:threadThread-63223:com.travimp.hotelierlinks.abba.service.CommunicationHandler$CommunicateWithExternalLinkService.run(): Received message [<?xml version="1.0" encoding="UTF-8" ?><Response ResponseReference="REF_P_028_841-4396-604024232212495" ResponseSequence="1"><ResponseDetails Language="en"><BookingResponse><BookingReferences><BookingReference ReferenceSource="client"><![CDATA[7ZYFO37092BWJ9P6ZNFV8IUGW]]></BookingReference><BookingReference ReferenceSource="agent"><![CDATA[502375]]></BookingReference><BookingReference ReferenceSource="api"><![CDATA[14000410]]></BookingReference></BookingReferences><BookingCreationDate>2012-05-21</BookingCreationDate><BookingDepartureDate>2012-08-20</BookingDepartureDate><BookingName><![CDATA[ANTHONY M PAOLUCCI]]></BookingName><BookingPrice Currency="CHF" Gross=".00" Commission=".00" Nett=".00"></BookingPrice><BookingStatus Code="X "><![CDATA[Cancelled]]></BookingStatus><PaxNames><PaxName PaxId="1"><![CDATA[ANTHONY M PAOLUCCI]]></PaxName><PaxName PaxId="2"><![CDATA[JENNIFER CHON]]></PaxName></PaxNames><BookingItems><BookingItem ItemType="hotel"><ItemReference>1</ItemReference><ItemCity Code="INTE"><![CDATA[Interlaken]]></ItemCity><Item Code="VIC"><![CDATA[Victoria-Jungfrau Grand Hotel & Spa]]></Item><ItemPrice Currency="CHF" Gross="517.00" Commission=".00" Nett="517.00"></ItemPrice><ItemStatus Code="X "><![CDATA[Cancelled]]></ItemStatus><ItemConfirmationReference>XX7F289323</ItemConfirmationReference><HotelItem><PeriodOfStay><CheckInDate>2012-08-20</CheckInDate><CheckOutDate>2012-08-21</CheckOutDate></PeriodOfStay><HotelRooms><HotelRoom Code="TB"><PaxIds><PaxId>1</PaxId><PaxId>2</PaxId></PaxIds></HotelRoom></HotelRooms><Meals><Basis Code="B"><![CDATA[Breakfast]]></Basis><Breakfast Code="F"><![CDATA[Full]]></Breakfast></Meals></HotelItem></BookingItem></BookingItems></BookingResponse></ResponseDetails></Response>] from [] in [16693] milliseconds.
Tue May 29 12:01:07 EDT 2012:threadWebContainer : 325:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=0}{sessionID=99}
  {Confirmation}{origLinkConfID=14000410}{hotelConfId=C$7ZYFO37092BWJ9P6ZNFV8IUGW}{linkConfID=14000410}{origHotelConfID=XX7F289323}{linkVersion=0}


Tue May 29 12:30:04 EDT 2012:threadWebContainer : 356:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request:  
{Header}{version=1.0}{clientVersion=1.0}{requestType=hotelCancelReservation}{clientID=TICS}{sessionID=99}
  {Cancellation}{destCode=NAS}{enddate=2012-07-30T00:00:00}{stdLinkCode=HBS_KERZNER}{hotelVersion=}{roomCode=UNT}{hotelConfID=1120136}{linkConfID=KP5rhsgKpZ}{ratePlanCode=C2BAR20}{hotelCode=COV}{mealPlanCode=EP}{channelType=A}{startDate=2012-07-26T00:00:00}{linkVersion=}
    {Pax}{firstName=RICHARD}{age=25}{lastName=MAYS}
    {Pax}{firstName=SUPHA}{age=25}{lastName=VANDIVER}
    
Tue May 29 12:30:04 EDT 2012:threadWebContainer : 356:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation response:  
{Header}{version=4.28}{requestType=hotelCancelReservation}{resultCode=1}{sessionID=99}
  {Error}{destCode=COV}{errorCode=1008}{hotelCode=NAS}{errorMessage=The system received a communication error from link HBS_KERZNER.  Please try your request again.}


Last edited by Scrutinizer; 06-23-2012 at 04:55 AM.. Reason: code tags
# 2  
Old 06-22-2012
Have a go with this:

Code:
awk '
    function print_last(    i )
    {
        if( keep )
            for( i = 0; i < cidx; i++ )
                print cache[i];
        printf( "\n" );                 # extra whitespace
    }

    /hotelCancelReservation request:/ { print_last( ); cidx = keep = 0 }
    /errorCode=1008/ { keep = 1; }
    { cache[cidx++] = $0; }

    END { print_last( ); }
' input-file >output-file

# 3  
Old 06-23-2012
Thanks but is it possible to refine it more like instead of printing the whole Cancel request if we can just give the linkConfID=BTCCo2yvMB from the request and the whole error code response.

For example like this. The inkConfID=BTCCo2yvMB failed with errorCode=1008.


Thanks again.
# 4  
Old 06-23-2012
This looks for the specific error code:

Code:
awk '
    function print_last(    i )
    {
        if( code != "" )
            printf( "The linkConfID %s failed with error 1008\n", id );
    }

    /hotelCancelReservation request:/ { print_last( ); code = "" }
    /{errorCode=/ {
        code = $0;
        gsub( ".*errorCode=", "", code );
        gsub( "}.*", "", code );
    }
    /{linkConfID=/ {
        id = $0;
        gsub( ".*linkConfID=", "", id );
        gsub( "}.*", "", id );
    }
    END { print_last( ); }
' input >output

I assumed that all of the information in the link confirmation ID was useful; printing just from the equal to the space yielded just 'B' in one case which seems less than desired.

Hope this gets you further.
# 5  
Old 06-23-2012
it works very closely but gives all the response say for error code=1035 and errorCode=1010 and etc but i need only Link_ConfID for errorCode=1008.I think u made it general for all "errorCode="
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. AIX

Grep a pattern and print following n lines

Hi all, I am struck with the below requirement. I need to grep a particular pattern in a file and then print next n lines of it for further processing. I have used the below code grep -A 3 "pattern" filename But it is throwing error as below. grep: illegal option -- A Can... (14 Replies)
Discussion started by: ssk250
14 Replies

3. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

4. Shell Programming and Scripting

awk to print all lines after a pattern is found

Is there a way with aw to print all lines after a string is found There is a file like this ....... ........ 2012/19/11 :11.58 PM some data lne no date 2012/19/11 :11.59 PM some other data 2012/20/11 :12.00 AM some other data some line without dates some more lines without dates... (8 Replies)
Discussion started by: swayam123
8 Replies

5. Shell Programming and Scripting

Sed print range of lines between line number and pattern

Hi, I have a file as below This is the line one This is the line two <\XMLTAG> This is the line three This is the line four <\XMLTAG> Output of the SED command need to be as below. This is the line one This is the line two <\XMLTAG> Please do the need to needful to... (4 Replies)
Discussion started by: RMN
4 Replies

6. Shell Programming and Scripting

Print lines between two strings multiple occurencies (with sed, awk, or grep)

Hello, I can extract lines in a file, between two strings but only one time. If there are multiple occurencies, my command show only one block. Example, monfichier.txt contains : debut_sect texte L1 texte L2 texte L3 texte L4 fin_sect donnees inutiles 1 donnees inutiles 2 ... (8 Replies)
Discussion started by: theclem35
8 Replies

7. Shell Programming and Scripting

AWK: Grep Pattern and print help

I wanted to get outcome from a big file with pattern quoted: Line FSP LSP SR RL Test1 100 300 4 4000 Test2 1 300 2 300 Any help is greatly appreciated. Thank you. (15 Replies)
Discussion started by: rtsiahaan
15 Replies

8. Shell Programming and Scripting

Print the above and below lines for the grep pattern.

Hi, i would like to get the above and below lines of the grep pattern . For ex : file as below: chk1- aaaa 1-Nov chk2 -aaaa ########## chk1-bbbbbb 1-Nov chk2-bbbbbb ######### my search pattern is date : 1-Nov i need the o/p as below chk1- aaaa 1-Nov (6 Replies)
Discussion started by: expert
6 Replies

9. Shell Programming and Scripting

sed print all lines after pattern match

HiCan someone show me how to print all lines from a file after a line matching a pattern using sed?Thanks (13 Replies)
Discussion started by: steadyonabix
13 Replies

10. Shell Programming and Scripting

How to awk/sed/grep lines which contains a pattern at a given position

Dear friends I am new to linux and was trying to split some files userwise in our linux server. I have a data file of 156 continuous columns named ecscr final. I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that,... (2 Replies)
Discussion started by: anoopvraj
2 Replies
Login or Register to Ask a Question