<?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 script to check file existence and notify in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413654#M706802</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Need help on my script. I wanted to have a script that will check the file in the directory, if not match then send e-mail to user. I have configured the mail the only thing is to make my script work.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt; &lt;BR /&gt;date=`date '+20%y-%d-%m'`&lt;BR /&gt; &lt;BR /&gt;#Check if file is match in the directory&lt;BR /&gt; &lt;BR /&gt;ls -ltr xyz.$date:*&lt;BR /&gt;&lt;BR /&gt;#if not the send to mail&lt;BR /&gt;&lt;BR /&gt;mailx -s "file not match" user@abc.foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check your file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;br,&lt;BR /&gt;Munawawr(script beginner)</description>
    <pubDate>Wed, 03 Nov 2004 02:52:28 GMT</pubDate>
    <dc:creator>Ahmad Munawwar</dc:creator>
    <dc:date>2004-11-03T02:52:28Z</dc:date>
    <item>
      <title>script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413654#M706802</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Need help on my script. I wanted to have a script that will check the file in the directory, if not match then send e-mail to user. I have configured the mail the only thing is to make my script work.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt; &lt;BR /&gt;date=`date '+20%y-%d-%m'`&lt;BR /&gt; &lt;BR /&gt;#Check if file is match in the directory&lt;BR /&gt; &lt;BR /&gt;ls -ltr xyz.$date:*&lt;BR /&gt;&lt;BR /&gt;#if not the send to mail&lt;BR /&gt;&lt;BR /&gt;mailx -s "file not match" user@abc.foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check your file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;br,&lt;BR /&gt;Munawawr(script beginner)</description>
      <pubDate>Wed, 03 Nov 2004 02:52:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413654#M706802</guid>
      <dc:creator>Ahmad Munawwar</dc:creator>
      <dc:date>2004-11-03T02:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413655#M706803</link>
      <description>One way to do it:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;today=$(date +%Y-%m-%d)&lt;BR /&gt;for file in xyz.${today}:* ; do&lt;BR /&gt;if [ ! -f $file ] ; then&lt;BR /&gt;mailx -s "${file}: file not match" user@foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check for file $file.&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Nov 2004 03:04:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413655#M706803</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2004-11-03T03:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413656#M706804</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;read the manpage for 'test'.&lt;BR /&gt;There you can find all possibilities to check a file:&lt;BR /&gt;-r file        True if file exists and is readable.&lt;BR /&gt;&lt;BR /&gt;-w file        True if file exists and is writable.&lt;BR /&gt;&lt;BR /&gt;-x file        True if file exists and is executable.&lt;BR /&gt;&lt;BR /&gt;-f file        True if file exists and is a regular file.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;and so forth&lt;BR /&gt;&lt;BR /&gt;Michael</description>
      <pubDate>Wed, 03 Nov 2004 03:41:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413656#M706804</guid>
      <dc:creator>Michael_356</dc:creator>
      <dc:date>2004-11-03T03:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413657#M706805</link>
      <description>We can check file exisence with [[ -f &lt;FILENAME&gt; there.&lt;BR /&gt;&lt;BR /&gt;Another way as, To do your work then,&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;date=`date '+20%y-%d-%m'`&lt;BR /&gt;&lt;BR /&gt;#Check if file is match in the directory&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ls -ltr "xyz.${date}:*" 1&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;#if not the send to mail&lt;BR /&gt;&lt;BR /&gt;if [[ $? -ne 0 ]]&lt;BR /&gt;then&lt;BR /&gt;mailx -s "file not match" user@abc.foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check your file&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;HTH&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 03 Nov 2004 03:57:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413657#M706805</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-11-03T03:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413658#M706806</link>
      <description>An asside to Muthukumur's reply.&lt;BR /&gt;Be careful with the use of the "new" test "operator" in guise of double square brackets [[ -f ... ]], especially in your intended context.&lt;BR /&gt;To my knowledge the "new" test construct does prevent word splitting and filename expansion.&lt;BR /&gt;So if you're inclined to use a shell globbing expression in a file test condition that would not work as expected&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;if [[ -d /app/oracle/product/[89].[12].[07] ]]; then&lt;BR /&gt;# do soemthing&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Nov 2004 04:09:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413658#M706806</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2004-11-03T04:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413659#M706807</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I use this way and it work I got the mail:-&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt; &lt;BR /&gt;#today=$(date+20%y-%d-%m)&lt;BR /&gt;date=`date '+20%y-%d-%m'`&lt;BR /&gt;for file in xyz.$date:*;do&lt;BR /&gt;if [ ! -f $file ];then&lt;BR /&gt;mailx -s "$(file): file not match" user@foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check for file $file&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;However when it found that the file not match then I got this additional message after run the script:-&lt;BR /&gt;usage: file [-c] [-f ffile] [-m mfile] [-h] file...&lt;BR /&gt;&lt;BR /&gt;where I should touch up this?&lt;BR /&gt;&lt;BR /&gt;br,&lt;BR /&gt;Munawawr&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Nov 2004 04:40:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413659#M706807</guid>
      <dc:creator>Ahmad Munawwar</dc:creator>
      <dc:date>2004-11-03T04:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413660#M706808</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;You should use the mailx command like this:&lt;BR /&gt;&lt;BR /&gt;mailx -s "$file: file not match" user@foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check for file $file&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;Currently you're using command substitution. So if you type file from your prompt you get the same message.&lt;BR /&gt;&lt;BR /&gt;Regards, MB.</description>
      <pubDate>Wed, 03 Nov 2004 05:09:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413660#M706808</guid>
      <dc:creator>Marcel Boogert_1</dc:creator>
      <dc:date>2004-11-03T05:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: script to check file existence and notify</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413661#M706809</link>
      <description>You are trying to execute file command as $(file) instead of using as ${file} or $file there.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;#today=$(date+20%y-%d-%m)&lt;BR /&gt;date=`date '+20%y-%d-%m'`&lt;BR /&gt;for file in xyz.${date}:*;do&lt;BR /&gt;if [ ! -f $file ];then&lt;BR /&gt;mailx -s "${file}: file not match" user@foo.com &amp;lt;&amp;lt; EOF&lt;BR /&gt;Please check for file $file&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;It will work there.&lt;BR /&gt;&lt;BR /&gt;HTH.</description>
      <pubDate>Wed, 03 Nov 2004 06:31:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-check-file-existence-and-notify/m-p/3413661#M706809</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-11-03T06:31:02Z</dc:date>
    </item>
  </channel>
</rss>

