<?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: Check for file multiple times in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235635#M687130</link>
    <description>James,&lt;BR /&gt;&lt;BR /&gt;Thank you sir !&lt;BR /&gt;&lt;BR /&gt;That works perfectly&lt;BR /&gt;&lt;BR /&gt;Many thanks for you help&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;John</description>
    <pubDate>Thu, 17 Jul 2008 11:51:54 GMT</pubDate>
    <dc:creator>John Crump</dc:creator>
    <dc:date>2008-07-17T11:51:54Z</dc:date>
    <item>
      <title>Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235629#M687124</link>
      <description>Please forgive this I think rather basic question.&lt;BR /&gt;&lt;BR /&gt;I have been away from UNIX for a very long time and am in need of some help.&lt;BR /&gt;&lt;BR /&gt;I need to be able to check for the existance of a specific file name say 'file.dat' in a particular location&lt;BR /&gt;&lt;BR /&gt;If the file exists then run a second process (at processname now)&lt;BR /&gt;&lt;BR /&gt;If the file does not exist then sleep 5 minutes and look for it again for up to 3 times&lt;BR /&gt;&lt;BR /&gt;Once the file has been found and processed once only then finish&lt;BR /&gt;&lt;BR /&gt;Any hints tips or specific examples would be appreciated&lt;BR /&gt;&lt;BR /&gt;Running HPUX by the way&lt;BR /&gt;&lt;BR /&gt;This is what I have so far&lt;BR /&gt;&lt;BR /&gt; The process searches up to 3 times for the arival of a file. Once it has detected the file and processed the job , it is important that it does not do so again. How can I prevent this?&lt;BR /&gt;&lt;BR /&gt;2 In this version of the code the script does not loop back to try again when the file is not found&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;file="/path/to/file/file.dat"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for i in 1 2 3&lt;BR /&gt;do&lt;BR /&gt;if [[ -f $file ]] ; then echo " file found"&lt;BR /&gt;at -f jtest_get_file.sh now&lt;BR /&gt;else&lt;BR /&gt;echo "File not found!".&lt;BR /&gt;&lt;BR /&gt;break&lt;BR /&gt;fi&lt;BR /&gt;sleep 3 # 3 seconds will be 600&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Jul 2008 08:49:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235629#M687124</guid>
      <dc:creator>John Crump</dc:creator>
      <dc:date>2008-07-17T08:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235630#M687125</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Suggest a while loop&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# your code&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 17 Jul 2008 08:51:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235630#M687125</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-07-17T08:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235631#M687126</link>
      <description>&amp;gt;Once it has detected the file and processed the job, it is important that it does not do so again.&lt;BR /&gt;&lt;BR /&gt;Well, you can remove the file.  You can rename/move the file.  Or you can change the permission on the file.&lt;BR /&gt;&lt;BR /&gt;Or you can create another file that says you processed the file.  Of course you need to clean up two files in order to start this process again.&lt;BR /&gt;&lt;BR /&gt;Or you can just exit the script?</description>
      <pubDate>Thu, 17 Jul 2008 09:16:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235631#M687126</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-17T09:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235632#M687127</link>
      <description>Steven,&lt;BR /&gt;&lt;BR /&gt;many thanks for your help so far&lt;BR /&gt;&lt;BR /&gt;I now have&lt;BR /&gt;&lt;BR /&gt;  &lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;for i in 1 2 3&lt;BR /&gt;do&lt;BR /&gt;if [[ -f $file ]] ; then echo " file found"&lt;BR /&gt;at -f jtest_get_file.sh now&lt;BR /&gt;extracted='y'&lt;BR /&gt;echo $extracted&lt;BR /&gt;else&lt;BR /&gt;echo "File not found!".&lt;BR /&gt;break&lt;BR /&gt;fi&lt;BR /&gt;sleep 3 # 3 seconds will be 600&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Unfortunatly it is now looping for ever&lt;BR /&gt;&lt;BR /&gt;By the way I see from your profile who you work for. I helped to impliment an Oracle based ERP system in your Southampton office in the UK&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 17 Jul 2008 09:17:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235632#M687127</guid>
      <dc:creator>John Crump</dc:creator>
      <dc:date>2008-07-17T09:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235633#M687128</link>
      <description>Dennis,&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;I am happy with both of your sugestions. I am fine with moving or re naming the file , but how would I exit the script after the secdond process has run once only?&lt;BR /&gt;&lt;BR /&gt;What is the syntax and where would I position it?&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 17 Jul 2008 09:23:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235633#M687128</guid>
      <dc:creator>John Crump</dc:creator>
      <dc:date>2008-07-17T09:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235634#M687129</link>
      <description>&lt;!--!*#--&gt;Hi John:&lt;BR /&gt;&lt;BR /&gt;Try this variation:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;look=0&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    if [[ -f "${file}" ]] ; then&lt;BR /&gt;        echo "'$file' file found"&lt;BR /&gt;        at -f jtest_get_file.sh now&lt;BR /&gt;        extracted='y'&lt;BR /&gt;        echo $extracted&lt;BR /&gt;        exit 0&lt;BR /&gt;    fi&lt;BR /&gt;    echo "File not found!"&lt;BR /&gt;    (( look=$look+1 ))&lt;BR /&gt;    [ $look -ge 3 ] &amp;amp;&amp;amp; exit 1&lt;BR /&gt;    sleep 3&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Jul 2008 11:19:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235634#M687129</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-17T11:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235635#M687130</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;Thank you sir !&lt;BR /&gt;&lt;BR /&gt;That works perfectly&lt;BR /&gt;&lt;BR /&gt;Many thanks for you help&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;John</description>
      <pubDate>Thu, 17 Jul 2008 11:51:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235635#M687130</guid>
      <dc:creator>John Crump</dc:creator>
      <dc:date>2008-07-17T11:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235636#M687131</link>
      <description>Hi John:&lt;BR /&gt;&lt;BR /&gt;You are welcome! ...please read too:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums12.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums12.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Jul 2008 12:05:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235636#M687131</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-17T12:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Check for file multiple times</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235637#M687132</link>
      <description>&lt;!-- !*# --&gt;&lt;P&gt;&amp;gt;I am happy with both of your suggestions. I am fine with moving or renaming the file, but how would I exit the script after the second process has run once only?&lt;BR /&gt;&amp;gt;What is the syntax and where would I position it?&lt;BR /&gt;&lt;BR /&gt;You can use exit to get out of the script, return to get out of the function. Or you can use break to get out of the loop.&lt;BR /&gt;I assume this is where your "echo $extracted" is?&lt;BR /&gt;extracted='y'&lt;BR /&gt;echo $extracted&lt;BR /&gt;break 2&lt;BR /&gt;&lt;BR /&gt;The "2" is needed to get out of both the "for" and "while" loops.&lt;BR /&gt;&lt;BR /&gt;I'm not sure why you want that while there? I assumed Steven meant replace that "for" loop by a while loop? (It's hard to use "for" for lots of times.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;file="???"&lt;BR /&gt;typeset -i count=3&lt;BR /&gt;extracted=&lt;BR /&gt;while (( (count -= 1) &amp;gt;= 0 )); do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ -f "${file}" ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "'$file' file found"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at -f jtest_get_file.sh now&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; extracted='y'&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $extracted&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "File not found!"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (( count == 0 )) &amp;amp;&amp;amp; break; # skip last sleep&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sleep $(( 5 * 60 )) # 5 minutes&lt;BR /&gt;done&lt;BR /&gt;# would need to test $extracted if desired&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2011 13:29:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/check-for-file-multiple-times/m-p/4235637#M687132</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-11T13:29:29Z</dc:date>
    </item>
  </channel>
</rss>

