<?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: using tail -f in a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831643#M721176</link>
    <description>Hi again,&lt;BR /&gt;sounds strange. I have just tried this:&lt;BR /&gt;&lt;BR /&gt;1) created a logfile&lt;BR /&gt;# touch /tmp/dunavent&lt;BR /&gt;&lt;BR /&gt;2) made the script dunavent.sh with this content:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;LOGFILE=/tmp/dunavent&lt;BR /&gt;tail -1f $LOGFILE | while read line&lt;BR /&gt;do&lt;BR /&gt;        echo $line | grep e&lt;BR /&gt;        if [ "$?" = "0" ]&lt;BR /&gt;        then&lt;BR /&gt;                # found&lt;BR /&gt;                echo $line &amp;gt;&amp;gt;./log_Y&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;3) executed dunavent.sh in the background:&lt;BR /&gt;# dunavent.sh &amp;amp;&lt;BR /&gt;&lt;BR /&gt;4) added lines to /tmp/dunavent&lt;BR /&gt;# echo "ee and e" &amp;gt;&amp;gt;/tmp/dunavent&lt;BR /&gt;&lt;BR /&gt;And all lines containing "e" are added to log_Y&lt;BR /&gt;(!?)&lt;BR /&gt;How did you do it?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 23 Oct 2002 13:11:41 GMT</pubDate>
    <dc:creator>john korterman</dc:creator>
    <dc:date>2002-10-23T13:11:41Z</dc:date>
    <item>
      <title>using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831631#M721164</link>
      <description>Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line. &lt;BR /&gt;&lt;BR /&gt;Here's what I am basically trying to do: &lt;BR /&gt;&lt;BR /&gt;tail -f log_X | grep n &amp;gt; log_Y &lt;BR /&gt;&lt;BR /&gt;I am doing a tail -f on log_X . Once it sees "n", I would like for it to grep it, then put it into log_Y. It ain't making it to log_Y. &lt;BR /&gt;&lt;BR /&gt;I have been manually adding "n" to log_X, and the tail command is definitely seeing it, but it fails to pass it to log_Y. &lt;BR /&gt;&lt;BR /&gt;Why? Is it because the command is trying to "complete" the tail -f before it executes the &amp;gt; (redirect) to log_Y?? &lt;BR /&gt;&lt;BR /&gt;Is there a better way to appraoch this? &lt;BR /&gt;&lt;BR /&gt;TYIA&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 12:03:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831631#M721164</guid>
      <dc:creator>Robert C. Dunavent</dc:creator>
      <dc:date>2002-10-23T12:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831632#M721165</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Use tail -100 log_X&lt;BR /&gt;&lt;BR /&gt;C.</description>
      <pubDate>Wed, 23 Oct 2002 12:09:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831632#M721165</guid>
      <dc:creator>Clemens van Everdingen</dc:creator>
      <dc:date>2002-10-23T12:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831633#M721166</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not sure if tail -f will work like you want it to.  If I were going to try to do it, I would use a Perl script and get the Tail module from CPAN.  The Tail module looks like it will do what you are looking for, and inside the Perl script you can grab what you need and write it to another file.  I'm sure one of the local Perl experts will pick up on this thread and show you how to really do it right.&lt;BR /&gt;&lt;BR /&gt;Just one way to try it.  &lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 12:12:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831633#M721166</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-23T12:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831634#M721167</link>
      <description>JP:&lt;BR /&gt;&lt;BR /&gt;That would be helpful...but, I don't know PERL.&lt;BR /&gt;&lt;BR /&gt;TYIA</description>
      <pubDate>Wed, 23 Oct 2002 12:23:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831634#M721167</guid>
      <dc:creator>Robert C. Dunavent</dc:creator>
      <dc:date>2002-10-23T12:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831635#M721168</link>
      <description>Hi,&lt;BR /&gt;you could also try something like this:&lt;BR /&gt;&lt;BR /&gt;tail -1f log_X | while read line&lt;BR /&gt;do&lt;BR /&gt;        echo $line | grep n&lt;BR /&gt;        if [ "$?" = "0" ]&lt;BR /&gt;        then&lt;BR /&gt;                # found, append&lt;BR /&gt;                echo $line &amp;gt;&amp;gt;/log_Y&lt;BR /&gt;&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 23 Oct 2002 12:31:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831635#M721168</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-10-23T12:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831636#M721169</link>
      <description>Before I try the PERL suggestion, lemme throw this out there.&lt;BR /&gt;&lt;BR /&gt;Lets suppose I do a ls -la /etc/myfile. Here's what I expect to see:&lt;BR /&gt;&lt;BR /&gt;-r--r--r--   1 root       sys          17867 Oct 21 13:37 /etc/myfile.&lt;BR /&gt;&lt;BR /&gt;I am interested in the file size of this file, which in this case is 17867.&lt;BR /&gt;&lt;BR /&gt;I could do a ls -la /etc/myfile | awk '{print $5}' and it would echo 17867...right?&lt;BR /&gt;&lt;BR /&gt;That's cool, but what if I want to do something other than printing $5. Let's say i wanna store it, then do something else based on it's value.&lt;BR /&gt;&lt;BR /&gt;For example (and I realize that STORE is not a real option here):&lt;BR /&gt;&lt;BR /&gt;ls -la /etc/myfile | awk '{STORE $5}'&lt;BR /&gt;&lt;BR /&gt;if [ $5 = 0 ];&lt;BR /&gt;    echo All is well&lt;BR /&gt;else&lt;BR /&gt;    echo All is not well&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What is the magic word here? I know it is not STORE. All I can find on using awk is the "print" option.&lt;BR /&gt;I don't wanna print $5, I wanna store it then use it in an IF statement.&lt;BR /&gt;&lt;BR /&gt;Ideas?&lt;BR /&gt;&lt;BR /&gt;TYIA&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 12:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831636#M721169</guid>
      <dc:creator>Robert C. Dunavent</dc:creator>
      <dc:date>2002-10-23T12:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831637#M721170</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can store the results of your ls command in a variable, and test that variable in an if statement.  Try something like this:&lt;BR /&gt;&lt;BR /&gt;FILESIZE=$ls -la /etc/myfile | awk '{STORE $5}') &lt;BR /&gt;&lt;BR /&gt;if (( $FILESIZE -eq = 17867 )); &lt;BR /&gt;echo All is well &lt;BR /&gt;else &lt;BR /&gt;echo All is not well &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 12:38:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831637#M721170</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-23T12:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831638#M721171</link>
      <description>Hi&lt;BR /&gt;you cam do the if-statement in awk:&lt;BR /&gt;ls -la /etc/myfile | awk '{if ( $5 == 0) print "ok"; else print "notok"}'&lt;BR /&gt;Chris</description>
      <pubDate>Wed, 23 Oct 2002 12:48:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831638#M721171</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2002-10-23T12:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831639#M721172</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm not sure if tail -f will work fine or not,but usually I use for example tail -50 or 150 logfile.&lt;BR /&gt;regards,&lt;BR /&gt;Hamdy</description>
      <pubDate>Wed, 23 Oct 2002 12:49:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831639#M721172</guid>
      <dc:creator>Hamdy Al-Sebaey</dc:creator>
      <dc:date>2002-10-23T12:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831640#M721173</link>
      <description>John K:&lt;BR /&gt;&lt;BR /&gt;   I tried your suggestion. Same thing happened...the tail catches the "n", but it is not passed to log_Y.&lt;BR /&gt;&lt;BR /&gt;?????&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TYIA</description>
      <pubDate>Wed, 23 Oct 2002 12:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831640#M721173</guid>
      <dc:creator>Robert C. Dunavent</dc:creator>
      <dc:date>2002-10-23T12:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831641#M721174</link>
      <description>Hi Robert,&lt;BR /&gt;&lt;BR /&gt;What about,for example&lt;BR /&gt;tail -50 /var/adm/syslog/syslog.log &amp;gt; /tmp/robert.&lt;BR /&gt;regards,&lt;BR /&gt;Hamdy</description>
      <pubDate>Wed, 23 Oct 2002 12:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831641#M721174</guid>
      <dc:creator>Hamdy Al-Sebaey</dc:creator>
      <dc:date>2002-10-23T12:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831642#M721175</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;My example is messed up.  I can't write shell scripts until I get enough caffeine into my system!&lt;BR /&gt;&lt;BR /&gt;Christian's awk example will do the job.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 12:57:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831642#M721175</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-10-23T12:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831643#M721176</link>
      <description>Hi again,&lt;BR /&gt;sounds strange. I have just tried this:&lt;BR /&gt;&lt;BR /&gt;1) created a logfile&lt;BR /&gt;# touch /tmp/dunavent&lt;BR /&gt;&lt;BR /&gt;2) made the script dunavent.sh with this content:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;LOGFILE=/tmp/dunavent&lt;BR /&gt;tail -1f $LOGFILE | while read line&lt;BR /&gt;do&lt;BR /&gt;        echo $line | grep e&lt;BR /&gt;        if [ "$?" = "0" ]&lt;BR /&gt;        then&lt;BR /&gt;                # found&lt;BR /&gt;                echo $line &amp;gt;&amp;gt;./log_Y&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;3) executed dunavent.sh in the background:&lt;BR /&gt;# dunavent.sh &amp;amp;&lt;BR /&gt;&lt;BR /&gt;4) added lines to /tmp/dunavent&lt;BR /&gt;# echo "ee and e" &amp;gt;&amp;gt;/tmp/dunavent&lt;BR /&gt;&lt;BR /&gt;And all lines containing "e" are added to log_Y&lt;BR /&gt;(!?)&lt;BR /&gt;How did you do it?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 13:11:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831643#M721176</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-10-23T13:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831644#M721177</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here is a shell which does it without a daemon :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;tail -f log_X |&amp;amp;&lt;BR /&gt;NPID=$!&lt;BR /&gt;while :&lt;BR /&gt;do&lt;BR /&gt;  read -p VAR&lt;BR /&gt;  echo $VAR | grep n &amp;gt; log || continue&lt;BR /&gt;  kill $!&lt;BR /&gt;  break&lt;BR /&gt;done&lt;BR /&gt;cat log&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Jean-Louis.&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 13:34:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831644#M721177</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2002-10-23T13:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: using tail -f in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831645#M721178</link>
      <description>John K:&lt;BR /&gt;&lt;BR /&gt;  Your script did the trick for me!!! Thanks!!&lt;BR /&gt;&lt;BR /&gt;-cd&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Oct 2002 15:50:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-tail-f-in-a-script/m-p/2831645#M721178</guid>
      <dc:creator>Robert C. Dunavent</dc:creator>
      <dc:date>2002-10-24T15:50:42Z</dc:date>
    </item>
  </channel>
</rss>

