Help with ksh scripting in AIX

I am looking for a script which does the following

Script will run daily.

1.It will get snapshot off all filesystems including nfs mounts, automounts and clearcase mounts.
2.Then it will compare new snapshot with the snapshot created in the previous run.
3.If filesystem exists in previous day snapshot and in new snapshot save file system in snapshot and continue.
4.If filesystem exists in new snapshot and does not exist in the previous day snapshot send an e-mail .
5.If filesystem exists in the previous day snapshot and does not exist in new snapshot send e-mail with high priority indicating the potential problems.
thx a lot !
sai

Anything you have tried so far on your own? Anything where got stuck in particular?

I tried this but looking for a better logic

HOSTNM=`hostname`
DATE=$(date +"%d-%b-%y %H:%M")
SHORTNAME="FileSystem Mount"
LONGNAME="Filesystem check"
#checking filesystem if its mounted or not
df -k |grep '/dev/hd4|/dev/hd2|/dev/hd9var|/dev/hd3|/dev/hd1|/proc|/dev/hd10opt|/dev/exportlv|/dev/optwarelv|/dev/orabinlv|/dev/ndmbinlv|/dev/oraclntlv|/dev/optswlv|/dev/cbnadlv|/dev/cbnabkplv|/dev/lvabinit1|/dev/lvappl|/dev/lveme|/dev/lvadmd1|/dev/lvserial|/dev/lvdata01|/dev/lvdata02|/dev/lvdata03|/dev/lvdata04|/dev/lvmeta1|/dev/lvabini1|/dev/lvstage1|/dev/lvfeed1|/dev/lvstage2|/dev/lvcmmigr|/dev/lvbkdata1|/dev/lvbkdata2|/dev/lvbkdata3|/dev/lvbkdata4|/dev/lveers1| /dev/expoptibmlv|/dev/expoptzloclv|/dev/performlv|/dev/sshcntllv|nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi|cchome01.core.afcc.com:/export/home' >d.txt
if [ d.txt == "1" ]
then
mail -s "Filesystem check pls inestigate "$DATE" "$HOSTNM" " xx@domain.com
else
mail -s "Filesystem check success  $DATE HOSTNM " xx@domain.com
fi
exit

I am looking for some good logic..Ofcourse this script was not working

---------- Post updated at 03:46 PM ---------- Previous update was at 11:10 AM ----------

Any help ..Most appreciated !

# I think the hostname is available as the preset var HOSTNAME.
# HOSTNM=`hostname`
DATE=$(date +"%d-%b-%y %H:%M")
SHORTNAME="FileSystem Mount"
LONGNAME="Filesystem check"
#I don't think grep supports |, just egrep.
# You can also break apart really, really long lines with backslashes
# so that it doesn't stretch your editor 3 miles wide.
#checking filesystem if its mounted or not
#df -k |grep '/dev/hd4|/dev/hd2|/dev/hd9var|/dev/hd3|/dev/hd1|/proc|...  >d.txt
# You can't just stick a file into []'s and expect it to work!
# You're probably trying to check the return code of grep instead, right?
# unfortunately, grep isn't going to work here since it'll return OK even if it
# finds only ONE of these filesystems.
#if [ d.txt == "1" ]
#then
#mail -s "Filesystem check pls inestigate "$DATE" "$HOSTNM" xx@domain.com
#else
#mail -s "Filesystem check success  $DATE HOSTNM " xx@domain.com
#fi
#exit

SUCCESS=0
# Create a temp file with a secure random name.
TMP=`mktemp`
df -h >$TMP
# Loop through each of these filesystems/paths individually.
# if I knew AIX well enough I might try reading from /etc/fstab instead
for DEV in /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
        /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
        /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
        /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
        /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
        /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
        /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
        /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
        /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
        /dev/expoptzloclv /dev/performlv|/dev/sshcntllv
        nasswd10v1prd\.nam\.nsroot\.net:/vol/ClearCase/cbnabi \
        cchome01\.core\.afcc\.com:/export/home
do
        # Check if grep can find the device in the file.  If not, set SUCCESS=1.
        # The -q flag tells grep to not print anything, all we need is the return code.
        grep -q "${DEV}" "${TMP}" || SUCCESS=1
done
# Delete the temp file.
rm -f "$TMP"

if [ "${SUCCESS}" -eq 0 ]
then
       mail -s "Filesystem check success $DATE $HOSTNAME" xx@domain.com 
else
       mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" xx@domain.com
fi

Somehow error is coming while i execute .Pls advice me some other logic as the clearcase mount doesnot start with /dev

Many thx and appreciate your help

thx again !

sai

My crystal ball is still in for maintenance. What error is coming up?

The script doesn't care if the clearcase mount starts with /dev/, you can put anything you want in that list.

Pls advice me if this logic works good as i find /etc/filesystems as aix dont have fstab

I hope this script logic is simple and less .Thanks for your advice .Pls advice anything wrong here

I am comparing the original etc/filesystem and todays .after comparing i will redirect it to a tmp file

pls advice again..U are gr8 would like your email address and phone number so that i can get good advice as i am looking for help for writting another script also

DATE=$(date +"%d-%b-%y %H:%M")
SHORTNAME="FileSystem Mount"
LONGNAME="Filesystem check"
TMP ="/home/cchome01/km17590/temp"
#I am storing the snapshot of the original filestem in /etc/filesystems as original.txt in my home directory
cat /etc/filesystems > today.txt
cmp original.txt today.txt >$TMP
grep -q "${TMP}" || SUCCESS= 

if [ "${SUCCESS}" -eq 0 ]
then
       mail -s "Filesystem check success $DATE $HOSTNAME" xx@domain.com 
else
       mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" xx@domain.com
#Delete the temp file.
rm -f "$TMP"
fi
 

Thx a lot
Sai

I don't think that will work. I doubt that /etc/filesystems changes. If AIX has a /proc/mtab that might be worth a try.

You can continue to get help here, you don't need my email address or telephone number. Besides, other folks might have better answers than me.

As for your previous question:

I'm still in the dark here. What error?

I am not able to crop the script what you had mentioned ..Appreciate if you can crop it and sent it ..

thx a lot !

sai

---------- Post updated at 02:39 PM ---------- Previous update was at 01:47 PM ----------

km17590@cbnap001c[20# ./gopalan
Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4          1048576    907448   14%     3929     2% /
/dev/hd2          2555904   1377372   47%    35234    10% /usr
/dev/hd9var       2097152   1955096    7%     2176     1% /var
/dev/hd3          3145728   3141496    1%       19     1% /tmp
/dev/hd1          2097152   2096484    1%        6     1% /lhome
/proc                   -         -    -         -     -  /proc
/dev/hd10opt      2097152    972580   54%     8828     4% /opt
/dev/exportlv       65536     64140    3%        7     1% /export
/dev/optwarelv       65536     64156    3%        5     1% /optware
/dev/orabinlv     2097152   2088308    1%        5     1% /optware/oracle
/dev/ndmbinlv     1048576    877836   17%     1485     1% /opt/cdunix
/dev/oraclntlv     4849664   2493804   49%     8768     2% /opt/oraClient
/dev/optswlv     10551296   8495064   20%     6072     1% /opt/sw
/dev/cbnadlv        65536     64136    3%       19     1% /cbnad
/dev/cbnabkplv       65536     64140    3%        8     1% /cbnabkp
/dev/lvabinit1     3145728   2052348   35%     5968     2% /opt/sw/abinitio
/dev/lvappl       4849664   4091500   16%     6307     1% /cbnad/data/appl
/dev/lveme       10354688   6994392   33%       89     1% /cbnad/data/eme
/dev/lvadmd1     10354688  10263764    1%     1338     1% /cbnad/data/admin
/dev/lvserial   314572800 305906528    3%     1382     1% /cbnad/data/serial
/dev/lvdata01   681574400 544718576   21%     1371     1% /cbnad/data/data01
/dev/lvdata02   681574400 544556824   21%     1370     1% /cbnad/data/data02
/dev/lvdata03   681574400 545085816   21%     1370     1% /cbnad/data/data03
/dev/lvdata04   681574400 544268116   21%     1370     1% /cbnad/data/data04
/dev/lvmeta1     10485760  10442876    1%        4     1% /cbnad/data/meta
/dev/lvabini1     2097152   2075244    2%     3026     1% /cbnad/data/abinitio
/dev/lvstage1   283115520 189556728   34%     2183     1% /cbnad/data/stage
/dev/lvfeed1   1730150400 1722278156    1%      491     1% /cbnad/feed
/dev/lvstage2     2228224   2218340    1%        4     1% /stage
/dev/lvcmmigr     1048576   1039896    1%        4     1% /cmmigr
/dev/lvbkdata1   131727360 131191920    1%        4     1% /cbnabkp/data01
/dev/lvbkdata2   131727360 131191920    1%        4     1% /cbnabkp/data02
/dev/lvbkdata3   131727360 131191920    1%        4     1% /cbnabkp/data03
/dev/lvbkdata4   131727360 131191920    1%        4     1% /cbnabkp/data04
/dev/lveers1       524288    519784    1%        4     1% /cbnad/EERS
/dev/expoptibmlv     6291456   3149788   50%    26575     4% /export/opt/IBM
/dev/expoptzloclv    10485760   6085100   42%    12920     1% /export/opt/z_local
/dev/performlv      786432    584864   26%     2021     2% /opt/perform
/dev/sshcntllv     1048576   1039892    1%        5     1% /opt/sw/sshcntl
nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi    61656272  52672936   15%     4079     1% /net/nasswd10v1prd/vol/ClearCase/cbnabi
cchome01.core.afcc.com:/export/home   282066944  52152264   82%   839861    34% /home/cchome01
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
grep: can't open
(Interrupt -- one more to kill letter)

And the script is here

  +1  # think the hostname is available as the preset var HOSTNAME.
    +2  # HOSTNM=`hostname`
    +3  DATE=$(date +"%d-%b-%y %H:%M")
    +4  SHORTNAME="FileSystem Mount"
    +5  LONGNAME="Filesystem check"
    +6  #I don't think grep supports |, just egrep.
    +7  # You can also break apart really, really long lines with backslashes
    +8  # so that it doesn't stretch your editor 3 miles wide.
    +9  #checking filesystem if its mounted or not
   +10  df -k |egrep '
   +11  [/dev/hd4|/dev/hd2|/dev/hd9var|/dev/hd3|/dev/hd1|/proc|/dev/hd10opt|/dev/exportlv|/dev/optwarelv|/dev/orabinlv|/dev/ndmbinlv|/dev/oraclntlv|/dev/opts
wlv|/dev/cbnadlv|/dev/cbnabkplv|/dev/lvabinit1|/dev/lvappl|/dev/lveme|/dev/lvadmd1|/dev/lvserial|/dev/lvdata01|/dev/lvdata02|/dev/lvdata03|/dev/lvdata04|/dev
/lvmeta1|/dev/lvabini1|/dev/lvstage1|/dev/lvfeed1|/dev/lvstage2|/dev/lvcmmigr|/dev/lvbkdata1|/dev/lvbkdata2|/dev/lvbkdata3|/dev/lvbkdata4|/dev/lveers1| /dev/
expoptibmlv|/dev/expoptzloclv|/dev/performlv|/dev/sshcntllv|nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi|cchome01.core.afcc.com:/export/home]'>d.txt
   +12
   +13  # You can't just stick a file into []'s and expect it to work!
   +14  # You're probably trying to check the return code of grep instead, right?
   +15  # unfortunately, grep isn't going to work here since it'll return OK even if it
   +16  # finds only ONE of these filesystems.
   +17  #if [ d.txt == "1" ]
   +18  #then
   +19  #mail -s "Filesystem check pls inestigate "$DATE" "$HOSTNM" xx@domain.com
   +20  #else
   +21  #mail -s "Filesystem check success  $DATE HOSTNM " xx@domain.com
   +22  #fi
   +23  #exit
   +24
   +25  SUCCESS=0
   +26  # Create a temp file with a secure random name.
   +27  TMP=`mktemp`
   +28  df -k >$TMP
   +29  # Loop through each of these filesystems/paths individually.
   +30  # if I knew AIX well enough I might try reading from /etc/fstab instead
   +31  for DEV in  /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
   +32          /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
   +33          /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
   +34          /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
   +35          /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
   +36          /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
   +37          /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
   +38          /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
   +39          /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
   +40          /dev/expoptzloclv /dev/performlv/dev/sshcntllv\
   +41          nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi \
   +42          cchome01.core.afcc.com:/export/home
   +43  do
   +44          # Check if grep can find the device in the file.  If not, set SUCCESS=1.
   +45          # The -q flag tells grep to not print anything, all we need is the return code.
   +46          grep -i "${DEV}" "${TMP}" || SUCCESS=1
   +47  done
   +48  # Delete the temp file.
   +49  rm -f "$TMP"
   +50
   +51  if [ "${SUCCESS}" -eq 0 ]
   +52  then
   +53         mail -s "Filesystem check success $DATE $HOSTNAME" xx@domain.com
   +54  else
   +55         mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" xx@domain.com
   +56  fi

AIX doesn't even have mktemp? Good grief...

Replace TMP=`mktemp` with TMP=/tmp/$$

You should also be commenting out or removing lines 10 and 11.

I am attaching the output when i run the script

km17590@cbnap001c[36]# ./gopalan
/dev/hd4          1048576    906760   14%     3929     2% /
/dev/hd2          2555904   1377372   47%    35234    10% /usr
/dev/hd9var       2097152   1954460    7%     2177     1% /var
/dev/hd3          3145728   3141492    1%       21     1% /tmp
/dev/hd1          2097152   2096484    1%        6     1% /lhome
/dev/hd10opt      2097152    976960   54%     8828     4% /opt
/proc                   -         -    -         -     -  /proc
/dev/hd10opt      2097152    976960   54%     8828     4% /opt
/dev/exportlv       65536     64140    3%        7     1% /export
/dev/optwarelv       65536     64156    3%        5     1% /optware
/dev/oraclntlv     4849664   2493804   49%     8768     2% /opt/oraClient
/dev/optswlv     10551296   8495064   20%     6072     1% /opt/sw
/dev/cbnadlv        65536     64136    3%       19     1% /cbnad
/dev/cbnabkplv       65536     64140    3%        8     1% /cbnabkp
/dev/lvabinit1     3145728   2052348   35%     5968     2% /opt/sw/abinitio
/dev/lvappl       4849664   4091500   16%     6307     1% /cbnad/data/appl
/dev/lveme       10354688   6994392   33%       89     1% /cbnad/data/eme
/dev/lvadmd1     10354688  10263764    1%     1338     1% /cbnad/data/admin
/dev/lvserial   314572800 305906528    3%     1382     1% /cbnad/data/serial
/dev/lvdata01   681574400 544718576   21%     1371     1% /cbnad/data/data01
/dev/lvdata02   681574400 544556824   21%     1370     1% /cbnad/data/data02
/dev/lvdata03   681574400 545085816   21%     1370     1% /cbnad/data/data03
/dev/lvdata04   681574400 544268116   21%     1370     1% /cbnad/data/data04
/dev/lvmeta1     10485760  10442876    1%        4     1% /cbnad/data/meta
/dev/lvabini1     2097152   2075244    2%     3026     1% /cbnad/data/abinitio
/dev/lvstage1   283115520 189556728   34%     2183     1% /cbnad/data/stage
/dev/lvfeed1   1730150400 1722278156    1%      491     1% /cbnad/feed
/dev/lvstage2     2228224   2218340    1%        4     1% /stage
/dev/lvcmmigr     1048576   1039896    1%        4     1% /cmmigr
/dev/lvbkdata1   131727360 131191920    1%        4     1% /cbnabkp/data01
/dev/lvbkdata2   131727360 131191920    1%        4     1% /cbnabkp/data02
/dev/lvbkdata3   131727360 131191920    1%        4     1% /cbnabkp/data03
/dev/lvbkdata4   131727360 131191920    1%        4     1% /cbnabkp/data04
/dev/lveers1       524288    519784    1%        4     1% /cbnad/EERS
/dev/expoptibmlv     6291456   3149788   50%    26575     4% /export/opt/IBM
/dev/expoptzloclv    10485760   6085092   42%    12920     1% /export/opt/z_local
nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi    61656272  52672936   15%     4079     1% /net/nasswd10v1prd/vol/ClearCase/cbnabi
cchome01.core.afcc.com:/export/home   282066944  52152264   82%   839861    34% /home/cchome01
(Interrupt -- one more to kill letter)

The script is not terminating

I am attaching the script which is corrected as per your advice

km17590@cbnap001c[37]# vi gopalan
"gopalan" 57 lines, 2889 characters
    +1  # think the hostname is available as the preset var HOSTNAME.
    +2  # HOSTNM=`hostname`
    +3  DATE=$(date +"%d-%b-%y %H:%M")
    +4  SHORTNAME="FileSystem Mount"
    +5  LONGNAME="Filesystem check"
    +6  #I don't think grep supports |, just egrep.
    +7  # You can also break apart really, really long lines with backslashes
    +8  # so that it doesn't stretch your editor 3 miles wide.
    +9  #checking filesystem if its mounted or not
   +10  df -k |egrep '
   +11  [/dev/hd4|/dev/hd2|/dev/hd9var|/dev/hd3|/dev/hd1|/proc|/dev/hd10opt|/dev/exportlv|/dev/optwarelv|/dev/orabinlv|/dev/ndmbinlv|/dev/oraclntlv|/dev/opts
wlv|/dev/cbnadlv|/dev/cbnabkplv|/dev/lvabinit1|/dev/lvappl|/dev/lveme|/dev/lvadmd1|/dev/lvserial|/dev/lvdata01|/dev/lvdata02|/dev/lvdata03|/dev/lvdata04|/dev
/lvmeta1|/dev/lvabini1|/dev/lvstage1|/dev/lvfeed1|/dev/lvstage2|/dev/lvcmmigr|/dev/lvbkdata1|/dev/lvbkdata2|/dev/lvbkdata3|/dev/lvbkdata4|/dev/lveers1| /dev/
expoptibmlv|/dev/expoptzloclv|/dev/performlv|/dev/sshcntllv|nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi|cchome01.core.afcc.com:/export/home]'>d.txt
   +12
   +13  # You can't just stick a file into []'s and expect it to work!
   +14  # You're probably trying to check the return code of grep instead, right?
   +15  # unfortunately, grep isn't going to work here since it'll return OK even if it
   +16  # finds only ONE of these filesystems.
   +17  #if [ d.txt == "1" ]
   +18  #then
   +19  #mail -s "Filesystem check pls inestigate "$DATE" "$HOSTNM" xx@domain.com
   +20  #else
   +21  #mail -s "Filesystem check success  $DATE HOSTNM " xx@domain.com
   +22  #fi
   +23  #exit
   +24
   +25  SUCCESS=0
   +26  # Create a temp file with a secure random name.
   +27  TMP=/tmp/$$
   +28  df -k >$TMP
   +29  # Loop through each of these filesystems/paths individually.
   +30  # if I knew AIX well enough I might try reading from /etc/fstab instead
   +31  for DEV in  /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
   +32          /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
   +33          /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
   +34          /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
   +35          /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
   +36          /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
   +37          /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
   +38          /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
   +39          /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
   +40          /dev/expoptzloclv /dev/performlv/dev/sshcntllv\
   +41          nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi \
   +42          cchome01.core.afcc.com:/export/home
   +43  do
   +44          # Check if grep can find the device in the file.  If not, set SUCCESS=1.
   +45          # The -q flag tells grep to not print anything, all we need is the return code.
   +46          grep -i "${DEV}" "${TMP}" || SUCCESS=1
   +47  done
   +48  # Delete the temp file.
   +49  rm -f "$TMP"
   +50
   +51  if [ "${SUCCESS}" -eq 0 ]
   +52  then
   +53         mail -s "Filesystem check success $DATE $HOSTNAME" xx@domain.com
   +54  else
   +55         mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" xx@domain.com
   +56  fi
   +57  exit

No it's not. You still need to comment out or remove lines 10 and 11.

I have done that still its not terminating.Pls help

thx!
sai

Please post the corrected script.

# think the hostname is available as the preset var HOSTNAME.
{
 [ "$_debug" == "on" ] &&  $@
}
debug set -x
# HOSTNM=`hostname`
DATE=$(date +"%d-%b-%y %H:%M")
SHORTNAME="FileSystem Mount"
LONGNAME="Filesystem check"
#I don't think grep supports |, just egrep.
# You can also break apart really, really long lines with backslashes
# so that it doesn't stretch your editor 3 miles wide.
#checking filesystem if its mounted or not
#df -k |egrep '
#[/dev/hd4|/dev/hd2|/dev/hd9var|/dev/hd3|/dev/hd1|/proc|/dev/hd10opt|/dev/exportlv|/dev/optwarelv|/dev/orabinlv|/dev/ndmbinlv|/dev/oraclntlv|/dev/optswlv|/dev/cbnadlv|/dev/cbnabkplv|/dev/lvabinit1|/dev/lvappl|/dev/lveme|/dev/lvadmd1|/dev/lvserial|/dev/lvdata01|/dev/lvdata02|/dev/lvdata03|/dev/lvdata04|/dev/lvmeta1|/dev/lvabini1|/dev/lvstage1|/dev/lvfeed1|/dev/lvstage2|/dev/lvcmmigr|/dev/lvbkdata1|/dev/lvbkdata2|/dev/lvbkdata3|/dev/lvbkdata4|/dev/lveers1| /dev/expoptibmlv|/dev/expoptzloclv|/dev/performlv|/dev/sshcntllv|nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi|cchome01.core.afcc.com:/export/home]'>d.txt

# You can't just stick a file into []'s and expect it to work!
# You're probably trying to check the return code of grep instead, right?
# unfortunately, grep isn't going to work here since it'll return OK even if it
# finds only ONE of these filesystems.
#if [ d.txt == "1" ]
#then
#mail -s "Filesystem check pls inestigate "$DATE" "$HOSTNM" xx@domain.com
#else
#mail -s "Filesystem check success  $DATE HOSTNM " xx@domain.com
#fi
#exit

SUCCESS=0
# Create a temp file with a secure random name.
TMP=/tmp/$$
df -k >$TMP
# Loop through each of these filesystems/paths individually.
# if I knew AIX well enough I might try reading from /etc/fstab instead
for DEV in  /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
        /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
        /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
        /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
        /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
        /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
        /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
        /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
        /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
        /dev/expoptzloclv /dev/performlv/dev/sshcntllv\
        nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi \
        cchome01.core.afcc.com:/export/home
do
        # Check if grep can find the device in the file.  If not, set SUCCESS=1.
        # The -q flag tells grep to not print anything, all we need is the return code.
        grep -i "${DEV}" "${TMP}" || SUCCESS=1
done
# Delete the temp file.
rm -f "$TMP"

if [ "${SUCCESS}" -eq 0 ]
then
       mail -s "Filesystem check success $DATE $HOSTNAME" kiran.kumar.mundiyath@citi.com 
#DEBUG set +x
else
       mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" kiran.kumar.mundiyath@citi.com
fi
#exit

---------- Post updated at 04:16 PM ---------- Previous update was at 04:14 PM ----------

[/COLOR]Pls adice and request you to crop the script and pls give me

The one I gave you was pretty much it.

With extra comments cropped:

#!/bin/ksh
SUCCESS=0

# Create a temp file with a secure random name.
TMP=/tmp/$$
df -k >$TMP
# Loop through each of these filesystems/paths individually.
# if I knew AIX well enough I might try reading from /etc/fstab instead
for DEV in   /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
        /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
        /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
        /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
        /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
        /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
        /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
        /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
        /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
        /dev/expoptzloclv /dev/performlv/dev/sshcntllv\
        nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi \
        cchome01.core.afcc.com:/export/home
do
        # Check if grep can find the device in the file.  If not, set SUCCESS=1.
        # The -q flag tells grep to not print anything, all we need is the return code.

        grep -q -i "${DEV}" "${TMP}" || SUCCESS=1
done
 
# Delete the temp file.
rm -f "$TMP"
 
if [ "${SUCCESS}" -eq 0 ]
then
        mail -s "Filesystem check success $DATE $HOSTNAME" kiran.kumar.mundiyath@citi.com
else
        mail -s "Filesystem check pls inestigate $DATE $HOSTNAME" kiran.kumar.mundiyath@citi.com
fi

I did add -q to grep, but that's just an aesthetic fix, it'll spam less. Are you sure it's not freezing on mail?

I really dont know whats wrong ..the script is not terminating

and i am not receiving any mail .I think so that the script is looking for a termination before the command to sent mail

Pls help!

run 'ps aux' in another terminal to see if you can tell what command it's frozen on.

Its is freezing in mail command ..I changed mail to mailx ..dont know whats wrong

thanks

sai

---------- Post updated at 11:25 AM ---------- Previous update was at 10:08 AM ----------

Hi i have checked the script and things are working but its not mailing

 sh -xv keep.sh
#!/bin/ksh
SUCCESS=0
+ SUCCESS=0

# Create a temp file with a secure random name.
TMP=/tmp/$$
+ TMP=/tmp/1069300
df -k >$TMP
+ df -k
+ 1> /tmp/1069300
# Loop through each of these filesystems/paths individually.
# if I knew AIX well enough I might try reading from /etc/fstab instead
for DEV in   /dev/hd4 /dev/hd2 /dev/hd9var /dev/hd3 /dev/hd1 \
        /proc /dev/hd10opt /dev/exportlv /dev/optwarelv \
        /dev/orabinlv/dev/ndmbinlv /dev/oraclntlv /dev/optswlv \
        /dev/cbnadlv /dev/cbnabkplv /dev/lvabinit1 /dev/lvappl \
        /dev/lveme /dev/lvadmd1 /dev/lvserial /dev/lvdata01 \
        /dev/lvdata02 /dev/lvdata03 /dev/lvdata04 /dev/lvmeta1 \
        /dev/lvabini1 /dev/lvstage1 /dev/lvfeed1 /dev/lvstage2 \
        /dev/lvcmmigr /dev/lvbkdata1 /dev/lvbkdata2 /dev/lvbkdata3 \
        /dev/lvbkdata4 /dev/lveers1 /dev/expoptibmlv \
        /dev/expoptzloclv /dev/performlv/dev/sshcntllv\
        nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi \
        cchome01.core.afcc.com:/export/home
do
        # Check if grep can find the device in the file.  If not, set SUCCESS=1.
        # The -q flag tells grep to not print anything, all we need is the return code.

        grep -q -i "${DEV}" "${TMP}" || SUCCESS=1
done
+ grep -q -i /dev/hd4 /tmp/1069300
+ grep -q -i /dev/hd2 /tmp/1069300
+ grep -q -i /dev/hd9var /tmp/1069300
+ grep -q -i /dev/hd3 /tmp/1069300
+ grep -q -i /dev/hd1 /tmp/1069300
+ grep -q -i /proc /tmp/1069300
+ grep -q -i /dev/hd10opt /tmp/1069300
+ grep -q -i /dev/exportlv /tmp/1069300
+ grep -q -i /dev/optwarelv /tmp/1069300
+ grep -q -i /dev/orabinlv/dev/ndmbinlv /tmp/1069300
+ SUCCESS=1
+ grep -q -i /dev/oraclntlv /tmp/1069300
+ grep -q -i /dev/optswlv /tmp/1069300
+ grep -q -i /dev/cbnadlv /tmp/1069300
+ grep -q -i /dev/cbnabkplv /tmp/1069300
+ grep -q -i /dev/lvabinit1 /tmp/1069300
+ grep -q -i /dev/lvappl /tmp/1069300
+ grep -q -i /dev/lveme /tmp/1069300
+ grep -q -i /dev/lvadmd1 /tmp/1069300
+ grep -q -i /dev/lvserial /tmp/1069300
+ grep -q -i /dev/lvdata01 /tmp/1069300
+ grep -q -i /dev/lvdata02 /tmp/1069300
+ grep -q -i /dev/lvdata03 /tmp/1069300
+ grep -q -i /dev/lvdata04 /tmp/1069300
+ grep -q -i /dev/lvmeta1 /tmp/1069300
+ grep -q -i /dev/lvabini1 /tmp/1069300
+ grep -q -i /dev/lvstage1 /tmp/1069300
+ grep -q -i /dev/lvfeed1 /tmp/1069300
+ grep -q -i /dev/lvstage2 /tmp/1069300
+ grep -q -i /dev/lvcmmigr /tmp/1069300
+ grep -q -i /dev/lvbkdata1 /tmp/1069300
+ grep -q -i /dev/lvbkdata2 /tmp/1069300
+ grep -q -i /dev/lvbkdata3 /tmp/1069300
+ grep -q -i /dev/lvbkdata4 /tmp/1069300
+ grep -q -i /dev/lveers1 /tmp/1069300
+ grep -q -i /dev/expoptibmlv /tmp/1069300
+ grep -q -i /dev/expoptzloclv /tmp/1069300
+ grep -q -i /dev/performlv/dev/sshcntllv /tmp/1069300
+ SUCCESS=1
+ grep -q -i nasswd10v1prd.nam.nsroot.net:/vol/ClearCase/cbnabi /tmp/1069300
+ grep -q -i cchome01.core.afcc.com:/export/home /tmp/1069300

# Delete the temp file.
rm -f "$TMP"
+ rm -f /tmp/1069300

if [ "${SUCCESS}" -eq 0 ]
then
mail -s "filesystem is good  $DATE" kiran.kumar.mundiyath@citi.com"

else
mail -s "filesystem is not good  $DATE" kiran.kumar.mundiyath@citi.com"
fi
+ [ 1 -eq 0 ]

Pls advice what is missing ..? the script is executing fully but not mailing

I can't help you with your MTA, sorry.