<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help with a script! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793435#M80384</link>
    <description>Harry, Procura!  I think I can't ask for more, excellent, just what I needed...  And now the learning is on me!</description>
    <pubDate>Mon, 26 Aug 2002 12:49:25 GMT</pubDate>
    <dc:creator>MAD_2</dc:creator>
    <dc:date>2002-08-26T12:49:25Z</dc:date>
    <item>
      <title>Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793407#M80356</link>
      <description>I would like to know if some of you can provide some ideas on how to start with a script here:&lt;BR /&gt;&lt;BR /&gt;Situation example (see attached file) -- Description:&lt;BR /&gt;1. Each two lines include date, time, a queue name, a fax ID number, a caseID number, the user ID, and the case type.&lt;BR /&gt;2. The file is a log and each data row is actually split into two lines each (there is an end of line character separating each row)&lt;BR /&gt;3. Most data rows contain the information as described in 1, however some (Errors) exclude parts of this information.&lt;BR /&gt;&lt;BR /&gt;Objective:&lt;BR /&gt;&lt;BR /&gt;1. To strip the file of the end of line characters separating each row (odd lines), placing each row of data into one line each.&lt;BR /&gt;2. To extract some of the data and put it into a raw file separated by any type of delimiter (pipes or commas is OK).  Data required is date, time (only hour+minutes+seconds), the faxID number, caseID number, UserID, and case type.&lt;BR /&gt;&lt;BR /&gt;As noted, some of the rows contain an "Error", in which case there is only a caseID, User, and Case type (no faxID).&lt;BR /&gt;&lt;BR /&gt;Ideas please...  Thanks.</description>
      <pubDate>Sun, 25 Aug 2002 15:07:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793407#M80356</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-25T15:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793408#M80357</link>
      <description>Oops, forgot the attachment, here it is:&lt;BR /&gt;</description>
      <pubDate>Sun, 25 Aug 2002 15:08:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793408#M80357</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-25T15:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793409#M80358</link>
      <description>Hi&lt;BR /&gt;Let us start with the first, merge two lines into one.&lt;BR /&gt;awk { $1="CaseId"  { line1=$0 ; getline line2 ; print line1 line2} } &lt;FILE.TXT&gt;&lt;BR /&gt;&lt;BR /&gt;I dont understand the lines with errors , the caseId after the error why is this not on a new line ?&lt;/FILE.TXT&gt;</description>
      <pubDate>Sun, 25 Aug 2002 16:06:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793409#M80358</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-25T16:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793410#M80359</link>
      <description>Sorry&lt;BR /&gt;You should include the ":" in the pattern. My example should look like:&lt;BR /&gt;&lt;BR /&gt;awk { $1="CaseId:" { line1=$0 ; getline line2 ; print line1 line2} } &lt;FILE.TXT&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/FILE.TXT&gt;</description>
      <pubDate>Sun, 25 Aug 2002 17:24:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793410#M80359</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-25T17:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793411#M80360</link>
      <description>Sorry for not replying earlier Leif, but here are the errors I get when trying your sample code:&lt;BR /&gt;syntax error The source line is 1.            &lt;BR /&gt;The error context is                          &lt;BR /&gt;                &amp;gt;&amp;gt;&amp;gt; { &amp;lt;&amp;lt;&amp;lt;                     &lt;BR /&gt;awk: The statement cannot be correctly parsed.&lt;BR /&gt;The source line is 1.                         &lt;BR /&gt;       awk: There is a missing } character.   &lt;BR /&gt;/FaxLog_strip.sh[2]: getline:  not found &lt;BR /&gt;&lt;BR /&gt;I also believe you misunderstand my scenario.  Each two lines represent one row, i.e. the following are two rows (4 lines in the sample file) -- the beginning of each row is an odd line in the file:&lt;BR /&gt;&lt;BR /&gt;&amp;lt;11/06 12:18:04.3786&amp;gt; Fax1.P5ixRCCC(377): FaxId: 2428                          &lt;BR /&gt; CaseId: 9956167 User: jc CaseType: LEAD                                       &lt;BR /&gt;&amp;lt;11/06 14:55:30.4643&amp;gt; Fax1.P5ixRCCC(383): **Error**  CaseId: 9956168 User: RF23&lt;BR /&gt;CaseType: COMPLAINT</description>
      <pubDate>Sun, 25 Aug 2002 19:40:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793411#M80360</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-25T19:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793412#M80361</link>
      <description>&lt;BR /&gt;#!/usr/contrib/bin/perl&lt;BR /&gt;$newrow=1;&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt; chop;&lt;BR /&gt; tr/ \t/ /s;&lt;BR /&gt; if ($newrow == 1) {&lt;BR /&gt;  $saverow = $_;&lt;BR /&gt;  $newrow = 0;&lt;BR /&gt; } else {&lt;BR /&gt;  $outrow = $saverow . " " . $_;&lt;BR /&gt;  $newrow=1;&lt;BR /&gt;  $f_datetime = $f_control = $f_faxid = $f_caseid = $f_user = $f_casetype = "";&lt;BR /&gt;  if ($outrow =~ /(&amp;lt;.*&amp;gt;) (.*:) (\*\*Error\*\*) (CaseId:) (.*) (User:) (.*) (CaseType:) (.*)/) {$f_datetime = $1; $f_control = $2; $f_faxid = $3; $f_caseid = $5; $f_user = $7; $f_casetype = $9;}&lt;BR /&gt;else {&lt;BR /&gt;  if ($outrow =~ /(&amp;lt;.*&amp;gt;) (.*:) (FaxId:) (.*) (CaseId:) (.*) (User:) (.*) (CaseType:) (.*)$/) {$f_datetime = $1; $f_control = $2; $f_faxid = $4; $f_caseid = $6; $f_user = $8; $f_casetype = $10;}&lt;BR /&gt; }&lt;BR /&gt; if ($f_datetime =~ /&amp;lt;(..)\/(.*) (..):(..):(..)\.(.*)&amp;gt;/) {$f_day=$1; $f_month=$2; &lt;BR /&gt;$f_hour=$3; $f_min=$4; $f_sec=$5;} printf("%s,%s,%s,%s,%s,%s,%s,%s,%s\n",$f_day,$f_month,$f_hour,$f_min,$f_sec,$f_faxid,$f_caseid,$f_user,$f_casetype);&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;/STDIN&gt;</description>
      <pubDate>Sun, 25 Aug 2002 19:54:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793412#M80361</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T19:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793413#M80362</link>
      <description>&lt;BR /&gt;In case that's too hard to read, I appended it and added some comments/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 25 Aug 2002 20:06:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793413#M80362</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T20:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793414#M80363</link>
      <description>I think I need some more coffee, let me try that again&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 25 Aug 2002 20:08:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793414#M80363</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T20:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793415#M80364</link>
      <description>Thanks Harry, where is the input (log) file specified?</description>
      <pubDate>Sun, 25 Aug 2002 20:10:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793415#M80364</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-25T20:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793416#M80365</link>
      <description>Thanks for the help so far; although I have not gotten very much ahead yet I must go today (I've been here since 4:30 AM)  But will keep pondering at this tomorrow morning...</description>
      <pubDate>Sun, 25 Aug 2002 20:15:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793416#M80365</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-25T20:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793417#M80366</link>
      <description>Sorry&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat inputfile | perlscript&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 25 Aug 2002 20:16:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793417#M80366</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T20:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793418#M80367</link>
      <description>&lt;BR /&gt;Save the script I gave you,&lt;BR /&gt;&lt;BR /&gt;check the path of perl,&lt;BR /&gt;&lt;BR /&gt;change permissions:&lt;BR /&gt;&lt;BR /&gt; chmod +x scriptname&lt;BR /&gt;&lt;BR /&gt;run program by:&lt;BR /&gt;&lt;BR /&gt; cat inputfile | scriptname&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 25 Aug 2002 20:18:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793418#M80367</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T20:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793419#M80368</link>
      <description>here's the output I got with your input:&lt;BR /&gt;&lt;BR /&gt;# cat input_file1 | ./input_exe3&lt;BR /&gt;29,05,12,15,36,1737  ,9956152,jc,COMPLAINT&lt;BR /&gt;30,05,14,13,07,2075  ,9956153,jc,LEAD&lt;BR /&gt;06,06,08,15,04,2419  ,9956165,KSHEN,COMPLAINT&lt;BR /&gt;11,06,11,49,14,2427  ,9956166,jc,LEAD&lt;BR /&gt;11,06,12,18,04,2428  ,9956167,jc,LEAD&lt;BR /&gt;11,06,14,55,30,**Error**,9956168,RF23,COMPLAINT&lt;BR /&gt;11,06,14,58,05,**Error**,9956169,RF23,COMPLAINT&lt;BR /&gt;11,06,14,59,23,**Error**,9956170,RF23,COMPLAINT&lt;BR /&gt;11,06,15,00,10,**Error**,9956171,RF23,COMPLAINT&lt;BR /&gt;11,06,15,01,12,**Error**,9956172,RF23,COMPLAINT&lt;BR /&gt;#                                                &lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 25 Aug 2002 20:22:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793419#M80368</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-25T20:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793420#M80369</link>
      <description>Hi&lt;BR /&gt;Yes I misunderstod you.&lt;BR /&gt;&lt;BR /&gt;First I should remove some unwanted characters, the example begins with two tabs.&lt;BR /&gt;cat orgfile |tr -d "\011" &amp;gt;tmpfile&lt;BR /&gt;mv tmpfile orgfile&lt;BR /&gt;&lt;BR /&gt;then supress repeating spaces&lt;BR /&gt;cat orgfile |tr -s " " &amp;gt;tmpfile&lt;BR /&gt;mv tmpfile orgfile&lt;BR /&gt;&lt;BR /&gt;When testing with awk it is better writing a awk script file and run awk with the -f option:&lt;BR /&gt;Example test.awk file:&lt;BR /&gt;&lt;BR /&gt;$1 ~ /^&lt;BR /&gt;Run this with&lt;BR /&gt;awk -f test.awk orgfile &amp;gt;tmpfile&lt;BR /&gt;&lt;BR /&gt;Now you can write a new awk script which extract your information ftom the tmpfile. As the fields mot appers in the same column in evry line you must write one awk line for evry &lt;BR /&gt;&lt;BR /&gt;example (I think you understand it):&lt;BR /&gt;&lt;BR /&gt;$5 == "Faxid:" {print $7 $8 $9}&lt;BR /&gt;$6 == "Faxid:" {print $8 $9 $10}&lt;BR /&gt;&lt;BR /&gt;When you get all this working you can write a shell sript which do all this with one command.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Aug 2002 06:54:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793420#M80369</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-08-26T06:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793421#M80370</link>
      <description>Harry, you basically produced a script I can use.  There were a couple of lines where I encountered some problems in the original file I am trying to clean, but I still need to look more into it.  &lt;BR /&gt;&lt;BR /&gt;Although I know nothing about Perl (except that maybe I should learn it!), I will attempt to read the script you gave me and try to make modifications to the code (if I can understand) to see if the problem can be fixed.  Thanks so much, the output looks much more like what I want.  And Leif, I appreciate your help, I still need to look into your last solution.</description>
      <pubDate>Mon, 26 Aug 2002 09:27:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793421#M80370</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-26T09:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793422#M80371</link>
      <description>Harry, can I get a little more help?  If you have the time. This is what is happening:&lt;BR /&gt;&lt;BR /&gt;1.  I made a few modifications to your original code (you can see the modified version attached), basically the output I would like to have is: date (DD/MO), time (HH:MM), FaxID, CaseID, UserID, and ComplaintType.&lt;BR /&gt;&lt;BR /&gt;2.  I do not know anything about Perl, so how to separate an output value like in the code below is a guessing trip for me:&lt;BR /&gt;# pattern match the time and break it down&lt;BR /&gt;if ($f_time =~ /(..):(..):(..)\.(.*)/) {  &lt;BR /&gt;$f_time=$1;}&lt;BR /&gt;&lt;BR /&gt;How do I make it look like $f_time = $1:$2? (to get HH:MM)&lt;BR /&gt;And for the date, how do I get rid of the "&amp;lt;" (to get DD/MO), I guess I would have to use something like:&lt;BR /&gt;if ($f_date =~ /(..)/(.*)/)&lt;BR /&gt;{$f_date= ????} -- to get $1/$2... I don't know.&lt;BR /&gt;&lt;BR /&gt;Attached you will see the modified code, and in the next I will provide a newer and more complete version of the log (since there are still some lines that concatenate when running)...</description>
      <pubDate>Mon, 26 Aug 2002 11:06:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793422#M80371</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-26T11:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793423#M80372</link>
      <description>This is a longer version of the log... I am just starting to like Perl!</description>
      <pubDate>Mon, 26 Aug 2002 11:08:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793423#M80372</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-26T11:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793424#M80373</link>
      <description>And this is how the output looks like, using the current script you gave me, for the log I just attached (too bad I could not include all three files at once)</description>
      <pubDate>Mon, 26 Aug 2002 11:09:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793424#M80373</guid>
      <dc:creator>MAD_2</dc:creator>
      <dc:date>2002-08-26T11:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793425#M80374</link>
      <description>Here's the new prog attached&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 26 Aug 2002 11:43:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793425#M80374</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-08-26T11:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a script!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793426#M80375</link>
      <description>If you are starting to like perl, please, please, please, upgrade to at least perl-5.6.1&lt;BR /&gt;&lt;BR /&gt;Not only do you get a much more featured perl, but you also get many more people that are able to help you.&lt;BR /&gt;&lt;BR /&gt;I know I am biased, but IMHO perl4 is dead. Dead as a doornail.&lt;BR /&gt;&lt;BR /&gt;Recent perl binaries can be fetched on my ITRC page https:/&lt;A href="http://www.beepz.com/personal/merijn" target="_blank"&gt;www.beepz.com/personal/merijn&lt;/A&gt; (compressed tar archive) or (just a teeny bit older from the HP porting centers as software depots). If you have any HP-UX application CD's newer than September 2001, you can install HP's perl-5.6.1 from the last CD of the set. Be aware though that this perl is not able to talk to Oracle (but starting as a perl newbee, you are not to be worried about it :)&lt;BR /&gt;&lt;BR /&gt;If you already know awk or sed, it's easy to learn how to solve the same problem in perl, since it ships with 'a2p' (awk2perl) and 's2p' (sed2perl) and loads of on-line documentation.&lt;BR /&gt;&lt;BR /&gt;If you are starting with perl, please don't learn perl4.&lt;BR /&gt;&lt;BR /&gt;perl4 is available as /usr/contrib/bin. Perl5 will be installed on /opt/perl&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN!</description>
      <pubDate>Mon, 26 Aug 2002 11:45:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-a-script/m-p/2793426#M80375</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-08-26T11:45:08Z</dc:date>
    </item>
  </channel>
</rss>

