<?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: cat /file to varaible in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611433#M675482</link>
    <description>&lt;!--!*#--&gt;&amp;gt; /usr/sbin/sendmail: Exec format error&lt;BR /&gt;&lt;BR /&gt;      uname -a&lt;BR /&gt;      ls -l /usr/sbin/sendmail&lt;BR /&gt;      file /usr/sbin/sendmail&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Did "root" do something like&lt;BR /&gt;    blah-blah-blah &amp;gt; /usr/sbin/sendmail&lt;BR /&gt;instead of:&lt;BR /&gt;    blah-blah-blah | /usr/sbin/sendmail&lt;BR /&gt;?</description>
    <pubDate>Fri, 02 Apr 2010 22:50:06 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2010-04-02T22:50:06Z</dc:date>
    <item>
      <title>cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611425#M675474</link>
      <description>Hi there I'm trying to crate a script which reads a log file content. Ho do I get an output of:&lt;BR /&gt;&lt;BR /&gt;cat /somefile.log to a string in Unix shell ?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Peter</description>
      <pubDate>Fri, 02 Apr 2010 05:04:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611425#M675474</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2010-04-02T05:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611426#M675475</link>
      <description>The output of any command (or a pipeline of commands) can be captured into a string by enclosing the command/pipeline with $( ).&lt;BR /&gt;&lt;BR /&gt;For example, if you want to read the first line of a file to an environment variable, you might do something like this:&lt;BR /&gt;&lt;BR /&gt;PIDVAR=$( head -1 /somewhere/file.pid )&lt;BR /&gt;&lt;BR /&gt;However, if you simply want to read the entire contents of the file into a string, you can use $(&amp;lt; ). This is faster than using $(cat /somefile.log), as the shell does not have to fork a new "cat" process. If your script does something repeatedly in a tight loop, this might have a significant effect on performance.&lt;BR /&gt;&lt;BR /&gt;Your example file could be read into a LOGVARIABLE by:&lt;BR /&gt;&lt;BR /&gt;LOGVARIABLE=$(&amp;lt; /somefile.log )&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Fri, 02 Apr 2010 06:05:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611426#M675475</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2010-04-02T06:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611427#M675476</link>
      <description>if you want to read it line by line you can also do&lt;BR /&gt;&lt;BR /&gt;typeset -i b=0&lt;BR /&gt;while read a&lt;BR /&gt;do&lt;BR /&gt;   b=b+1&lt;BR /&gt;   echo line "$b:$a"&lt;BR /&gt;done &lt;SOMEFILE.LOG&gt;&lt;/SOMEFILE.LOG&gt;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;exec 3&lt;SOMEFILE.LOG&gt;&lt;/SOMEFILE.LOG&gt;while read -u3 a&lt;BR /&gt;do&lt;BR /&gt;   b=b+1&lt;BR /&gt;   echo line "$b:$a"&lt;BR /&gt;done</description>
      <pubDate>Fri, 02 Apr 2010 07:16:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611427#M675476</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2010-04-02T07:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611428#M675477</link>
      <description>&lt;P&gt;&amp;gt;Laurent: b=b+1&lt;BR /&gt;&lt;BR /&gt;You'll need to use: (( b = b + 1 ))&lt;/P&gt;&lt;P&gt;Or: (( b += 1 ))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;gt;exec 3&amp;lt; somefile.log&lt;BR /&gt;&lt;BR /&gt;You should probably close it when you are done:&lt;BR /&gt;exec 3&amp;lt;&amp;amp;-&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2011 22:58:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611428#M675477</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-08-21T22:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611429#M675478</link>
      <description>Hi Peter:&lt;BR /&gt;&lt;BR /&gt;You can also create/capture a shell 'here-document' into a string should the need arise:&lt;BR /&gt;&lt;BR /&gt;LIST=$(&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo ${LINE}&lt;BR /&gt;done &amp;lt;&amp;lt;- EOF!&lt;BR /&gt;file1&lt;BR /&gt;file2&lt;BR /&gt;file3&lt;BR /&gt;EOF!&lt;BR /&gt;)&lt;BR /&gt;echo ${LIST}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 02 Apr 2010 09:55:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611429#M675478</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-04-02T09:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611430#M675479</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;Hi there I'm trying to crate a script which reads a log file content. Ho do I get an output of:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you can try to grep the strings which you are searching in log.&lt;BR /&gt;like if i need to search EMS strings in /var/adm/syslog/syslog.log then I will do&lt;BR /&gt;&lt;BR /&gt;grep -i ems /var/adm/syslog/syslog.log&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
      <pubDate>Fri, 02 Apr 2010 10:22:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611430#M675479</guid>
      <dc:creator>Suraj K Sankari</dc:creator>
      <dc:date>2010-04-02T10:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611431#M675480</link>
      <description>&amp;gt;&amp;gt;Laurent: b=b+1&lt;BR /&gt;&amp;gt;You'll need to use: (( b = b + 1 ))&lt;BR /&gt;No in ksh or posix shell since I typed b with&lt;BR /&gt;typeset -i b=0, I don't need to use&lt;BR /&gt;(( ))&lt;BR /&gt;&lt;BR /&gt;# typeset -i b=0&lt;BR /&gt;# b=b+1&lt;BR /&gt;# echo $b&lt;BR /&gt;1&lt;BR /&gt;# b=b+1&lt;BR /&gt;# echo $b&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;exec 3&amp;lt; somefile.log&lt;BR /&gt;&lt;BR /&gt;&amp;gt;You should probably close it when you are &amp;gt;done:&lt;BR /&gt;&amp;gt;exec 3&amp;lt;&amp;amp;-&lt;BR /&gt;indeed it is cleaner to close it once the loop read all the file so at loop exit.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Apr 2010 10:53:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611431#M675480</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2010-04-02T10:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611432#M675481</link>
      <description>Thanks for all the responses. &lt;BR /&gt;I got stock on the e-mail part. I was always using this:&lt;BR /&gt;&lt;BR /&gt;echo "test" |mail -s "test" yyy@xxx.com&lt;BR /&gt;&lt;BR /&gt;But this time I got the following error:&lt;BR /&gt;/usr/sbin/sendmail: Exec format error&lt;BR /&gt;&lt;BR /&gt;If I try this:&lt;BR /&gt;&lt;BR /&gt;cat /somefile.log &amp;lt;&amp;lt; EOF | sendmail -t&lt;BR /&gt;to:xxx@yyy.com&lt;BR /&gt;from:xxx@yyy.com&lt;BR /&gt;subject:Testing 123&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;There is no error but I'm not getting the email either.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please advice&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Apr 2010 21:06:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611432#M675481</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2010-04-02T21:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611433#M675482</link>
      <description>&lt;!--!*#--&gt;&amp;gt; /usr/sbin/sendmail: Exec format error&lt;BR /&gt;&lt;BR /&gt;      uname -a&lt;BR /&gt;      ls -l /usr/sbin/sendmail&lt;BR /&gt;      file /usr/sbin/sendmail&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Did "root" do something like&lt;BR /&gt;    blah-blah-blah &amp;gt; /usr/sbin/sendmail&lt;BR /&gt;instead of:&lt;BR /&gt;    blah-blah-blah | /usr/sbin/sendmail&lt;BR /&gt;?</description>
      <pubDate>Fri, 02 Apr 2010 22:50:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611433#M675482</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2010-04-02T22:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to varaible</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611434#M675483</link>
      <description>Peter,&lt;BR /&gt;&lt;BR /&gt;Instead of mail  try mailx  in hp-ux and it will work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ echo "test" |mailx -s "test-mail" yyy@xxx.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;More info :&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/5992-5835/ar01s04.html" target="_blank"&gt;http://docs.hp.com/en/5992-5835/ar01s04.html&lt;/A&gt;&lt;BR /&gt;( mailx example in : 2. b. )&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Apr 2010 22:54:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611434#M675483</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2010-04-02T22:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: cat /file to variable</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611435#M675484</link>
      <description>&lt;P&gt;&amp;gt;Laurent: No, in ksh or posix shell since I typed b with typeset -i b=0&lt;BR /&gt;&lt;BR /&gt;Wow thanks! I tried it and it worked but it wasn't obvious where it was documented. I found it but it didn't have yellow highlighter on it. ;-)&lt;BR /&gt;&lt;BR /&gt;Unfortunately you would have to use "" if you have spaces: b="b + 1"&lt;BR /&gt;So maybe using (( )) makes it more visually obvious.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: You can also create/capture a shell 'here-document' into a string should the need arise:&lt;BR /&gt;&lt;BR /&gt;It might be cleaner to use an evil cat in this case. :-)&lt;BR /&gt;Unfortunately you can't use:&lt;BR /&gt;$(&amp;lt; &amp;lt;ccc&lt;BR /&gt;EOF&lt;BR /&gt;)&lt;BR /&gt;But you can replace that "&amp;lt;" by "cat".&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2011 22:59:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cat-file-to-varaible/m-p/4611435#M675484</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-08-21T22:59:01Z</dc:date>
    </item>
  </channel>
</rss>

