<?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: read data in a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942641#M798580</link>
    <description>Shalom Patrice,&lt;BR /&gt;&lt;BR /&gt;while read -r dataline&lt;BR /&gt;do&lt;BR /&gt;  echo $dataline&lt;BR /&gt;  # perhaps awk -F: '{print $2}'&lt;BR /&gt;  # for further procesing&lt;BR /&gt;done &amp;lt; filename&lt;BR /&gt;&lt;BR /&gt;SEP</description>
    <pubDate>Wed, 23 Nov 2005 12:03:17 GMT</pubDate>
    <dc:creator>Steven E. Protter</dc:creator>
    <dc:date>2005-11-23T12:03:17Z</dc:date>
    <item>
      <title>read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942640#M798579</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;what's the command to read the data in a file?  I have a file and if a do the command:&lt;BR /&gt;grep Customer file&lt;BR /&gt;it returns:&lt;BR /&gt;file:Customer : 269852&lt;BR /&gt;&lt;BR /&gt;How can i read the 269852 ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;PB</description>
      <pubDate>Wed, 23 Nov 2005 12:00:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942640#M798579</guid>
      <dc:creator>Patrice Blanchard_2</dc:creator>
      <dc:date>2005-11-23T12:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942641#M798580</link>
      <description>Shalom Patrice,&lt;BR /&gt;&lt;BR /&gt;while read -r dataline&lt;BR /&gt;do&lt;BR /&gt;  echo $dataline&lt;BR /&gt;  # perhaps awk -F: '{print $2}'&lt;BR /&gt;  # for further procesing&lt;BR /&gt;done &amp;lt; filename&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 23 Nov 2005 12:03:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942641#M798580</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2005-11-23T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942642#M798581</link>
      <description>You need to define your problem a little better. Do you only want to return lines that contain "Customer"? Might more than one line in the file contain "Customer"?. Is the field separator always ":"? Is the customer number always the last field in the line -- or, perhaps, always immediately follows "Customer:"?</description>
      <pubDate>Wed, 23 Nov 2005 12:06:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942642#M798581</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-23T12:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942643#M798582</link>
      <description>Let's put it this way,&lt;BR /&gt;&lt;BR /&gt;i want to be able to catch the customer number in a file generated by my ERP system so that i could send an email by mailx.&lt;BR /&gt;&lt;BR /&gt;So the process woulb by:&lt;BR /&gt;fetch the customer number in a file then read another file with that customer number to get the email address so i can send an email by mailx.&lt;BR /&gt;&lt;BR /&gt;file1 would have Customer : 268852&lt;BR /&gt;file2 would have 268852 email@somewhere.com&lt;BR /&gt;&lt;BR /&gt;then i could do a mailx to email@somewhere.com&lt;BR /&gt;&lt;BR /&gt;is it feasible?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;PB</description>
      <pubDate>Wed, 23 Nov 2005 12:14:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942643#M798582</guid>
      <dc:creator>Patrice Blanchard_2</dc:creator>
      <dc:date>2005-11-23T12:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942644#M798583</link>
      <description>You are still not defining the problem precisely enough. Does your file1 contain only 1 line with customer or does it contain many different customers? Are there other lines in the file which should be ignored? &lt;BR /&gt;&lt;BR /&gt;Very similar questions for line 2: Does it contain only one customer number?&lt;BR /&gt;&lt;BR /&gt;It would be very helpful if you listed a dataset of file1 and file2 -- unless you already have and these are simply one line files.</description>
      <pubDate>Wed, 23 Nov 2005 12:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942644#M798583</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-23T12:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942645#M798584</link>
      <description>Sorry about that, i forgot that part when i did my reply.&lt;BR /&gt;&lt;BR /&gt;file1 is an invoice for 1 customer so you'll have multiple lines in file1 but only 1 line with Customer : xxxxxx so you'll have something like:&lt;BR /&gt;&lt;BR /&gt;invoice&lt;BR /&gt;blablabla&lt;BR /&gt;customer: 258965&lt;BR /&gt;blablabla&lt;BR /&gt;line 1 item price&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;file2 would have multiple customer number, 1 per line so you'll have something like this:&lt;BR /&gt;268852 email1&lt;BR /&gt;245896 email2&lt;BR /&gt;256974 email3&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Nov 2005 12:45:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942645#M798584</guid>
      <dc:creator>Patrice Blanchard_2</dc:creator>
      <dc:date>2005-11-23T12:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942646#M798585</link>
      <description>Something like this should work-&lt;BR /&gt; &lt;BR /&gt;cust=`awk '/^customer:/{print $2}'`&lt;BR /&gt;if [[ "x$cust" = "x" ]] ; then echo "no customer line..." ; exit ; fi&lt;BR /&gt;email=`awk '/^${cust}/{print $2}'`&lt;BR /&gt;if [[ "x$email" = "x" ]] ; then echo "no email for $cust" ; exit ; fi&lt;BR /&gt;mailx -s "subj" $email &lt;MSGFILE&gt;&lt;/MSGFILE&gt; &lt;BR /&gt;Note I added code to exit if it can't find the data in the file&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 23 Nov 2005 13:02:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942646#M798585</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-11-23T13:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942647#M798586</link>
      <description>Okay, given that here is a fairly robust solution (provided that I don't make any typing booboo's):&lt;BR /&gt;&lt;BR /&gt;--------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset PROG=${0##*/}&lt;BR /&gt;&lt;BR /&gt;if [[ ${#} -lt 2 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${PROG}: requires 2 arguments" &amp;gt;&amp;amp;2&lt;BR /&gt;    exit 250&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;typeset FILE1=${1}&lt;BR /&gt;typeset FILE2=${2}&lt;BR /&gt;shift 2&lt;BR /&gt;&lt;BR /&gt;if [[ ! -r ${FILE1} || ! -f ${FILE1} ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${PROG}: Can't open ${FILE1}" &amp;gt;&amp;amp;2&lt;BR /&gt;    exit 248&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;if [[ ! -r ${FILE2} || ! -f ${FILE2} ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${PROG}: Can't open ${FILE2}" &amp;gt;&amp;amp;2&lt;BR /&gt;    exit 246&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=255&lt;BR /&gt;typeset CNUM=$(awk -F ':' '/Customer/{print $NF; exit(0)}' ${FILE1})&lt;BR /&gt;if [[ -n "${CNUM}" ]]&lt;BR /&gt;  then&lt;BR /&gt;    STAT=254&lt;BR /&gt;    typeset A=$(echo "{ if (\$1 == target) {print \$0; exit(0)}}")&lt;BR /&gt;    typeset ADDRESS=""&lt;BR /&gt;    typeset DUMMY=""&lt;BR /&gt;    awk -v "target=${CNUM}" "${A}" ${FILE2} | read DUMMY ADDRESS&lt;BR /&gt;    if [[ -n "${ADDRESS}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        echo "Cnum: ${CNUM}"&lt;BR /&gt;        echo "Address: ${ADDRESS}"&lt;BR /&gt;        STAT=0&lt;BR /&gt;      fi &lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;--------------------------------------&lt;BR /&gt;&lt;BR /&gt;At the point where I am echo'ing ${CNUM} and ${ADDRESS} is where you should build your mailx command.&lt;BR /&gt;&lt;BR /&gt;Invoke the script like this:&lt;BR /&gt;myscript.sh /xxx/yyy/file1 /zzz/ttt/file2&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Nov 2005 13:37:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942647#M798586</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-23T13:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942648#M798587</link>
      <description>PB,&lt;BR /&gt;&lt;BR /&gt;You probably have a bunch of invoice files no?&lt;BR /&gt;&lt;BR /&gt;So you may want to consider to read the email files once and just remember all the number to email combo's &lt;BR /&gt;&lt;BR /&gt;Then loop through the input files.&lt;BR /&gt;&lt;BR /&gt;Working perl example below.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---- invoice_email.pl ------------&lt;BR /&gt;$email = shift @ARGV or die "Please provide number-email file";&lt;BR /&gt;$invoices = shift @ARGV or die "Please provide invoice file specs";&lt;BR /&gt;open X, "&amp;lt;$email" or die "Could not open number-email file $email";&lt;BR /&gt;while (&lt;X&gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  ($number, $address) = split;&lt;BR /&gt;  $addresses{$number} = $address;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;foreach (glob $invoices) {&lt;BR /&gt;  open X, "&amp;lt;$_" or die "Could not open invoice file $_";&lt;BR /&gt;  while (&lt;X&gt;) {&lt;BR /&gt;    if (/customer:\s+(\d+)/) {&lt;BR /&gt;      $number = $1;&lt;BR /&gt;          $address = $addresses{$number};&lt;BR /&gt;      if ($address) {&lt;BR /&gt;         print "system ( mailx -s $number $address ... goes here\n)";&lt;BR /&gt;        } else {&lt;BR /&gt;                print "No Email address found for customer: $number\n";&lt;BR /&gt;            }&lt;BR /&gt;     }&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;------- sample run ------&lt;BR /&gt;/tmp]$ perl x.p email "invo*"&lt;BR /&gt;No Email address found for customer: 258965&lt;BR /&gt;system ( mailx -s 268852 email1 ... goes here)&lt;BR /&gt;system ( mailx -s 245896 email2 ... goes here)&lt;BR /&gt;&lt;BR /&gt;-------- input date -----&lt;BR /&gt;&lt;BR /&gt;# grep  "cust" invo*&lt;BR /&gt;invoice1:customer: 258965&lt;BR /&gt;invoice2:customer: 268852&lt;BR /&gt;invoice3:customer: 245896&lt;BR /&gt;# cat email&lt;BR /&gt;268852 email1&lt;BR /&gt;245896 email2&lt;BR /&gt;256974 email3&lt;BR /&gt;&lt;/X&gt;&lt;/X&gt;</description>
      <pubDate>Wed, 23 Nov 2005 14:02:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942648#M798587</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-11-23T14:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942649#M798588</link>
      <description>Do you mean that,&lt;BR /&gt;&lt;BR /&gt;Get Customer number from file and grep that in file2 and get the mail Id and send invoice?&lt;BR /&gt;&lt;BR /&gt;Then,&lt;BR /&gt;&lt;BR /&gt;# cat file1&lt;BR /&gt;invoice&lt;BR /&gt;blablabla&lt;BR /&gt;customer: 258965&lt;BR /&gt;blablabla&lt;BR /&gt;line 1 item price&lt;BR /&gt;...&lt;BR /&gt;# cat file2&lt;BR /&gt;268852 email1&lt;BR /&gt;245896 email2&lt;BR /&gt;256974 email3&lt;BR /&gt;258965 email@somewhere.com&lt;BR /&gt;# awk '/[Cc]ustomer:/ { print $2 }' file1 | xargs -i grep {} file2 | awk '{ print $2 }'&lt;BR /&gt;email@somewhere.com&lt;BR /&gt;&lt;BR /&gt;# mailx -s "subject" $(awk '/[Cc]ustomer:/ { print $2 }' file1 | xargs -i grep {} file2 | awk '{ print $2 }') &amp;lt; messagefile&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Thu, 24 Nov 2005 04:41:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942649#M798588</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-11-24T04:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: read data in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942650#M798589</link>
      <description>Thanks all for your help.&lt;BR /&gt;&lt;BR /&gt;PB</description>
      <pubDate>Mon, 28 Nov 2005 14:25:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/read-data-in-a-file/m-p/4942650#M798589</guid>
      <dc:creator>Patrice Blanchard_2</dc:creator>
      <dc:date>2005-11-28T14:25:37Z</dc:date>
    </item>
  </channel>
</rss>

