Hello I have two files as follow:
man_exist_instances.txt
2100_ctxd
2100_sfgd
2200_sfga
2200_ctxa
2150_sfgi
2150_ctxi
2250_sfgm
2500_ctxd
AND
sys_exist_instances.txt
2650_sfg
2250_sfg
sfga_220
2700_etx
2250_ctx
2650_etx
2100_sfg
2200_ctx
2150_sfg
The objective is to compare man_exist_instances.txt to sys_exist_instances.txt, and generate:
result_instances.txt
2400_etx
2450_etx
2600_etx
2650_etx
sfga_220
sfga_220
The next thing is to take each line in result_instances.txt, obtain full name from man_exist_instances.txt to produce final file_mail.txt.
Last request is to attach the file file_mail.txt to an email and send it to usera.
Here is my attempt
Howevern when I execute above, I am getting:
./chk_eventmon_new.sh[25]: man_exist_instances.txt]:
However I do have man_exist_instances.txt
-rwxrwxr-x 1 oracle dba 180 Mar 30 16:45 man_exist_instances.txt
-rw-r--r-- 1 oracle dba 0 Mar 31 11:01 file_mail.txt
-rwxr-x--- 1 oracle dba 1337 Mar 31 11:58 chk_eventmon_new.sh
-rw-r--r-- 1 oracle dba 180 Mar 31 12:09 sys_exist_instances.txt
-rw-r--r-- 1 oracle dba 54 Mar 31 12:09 result_instances.txt
Please help
man_exist_instances.txt
2100_ctxd
2100_sfgd
2200_sfga
2200_ctxa
2150_sfgi
2150_ctxi
2250_sfgm
2500_ctxd
AND
sys_exist_instances.txt
2650_sfg
2250_sfg
sfga_220
2700_etx
2250_ctx
2650_etx
2100_sfg
2200_ctx
2150_sfg
The objective is to compare man_exist_instances.txt to sys_exist_instances.txt, and generate:
result_instances.txt
2400_etx
2450_etx
2600_etx
2650_etx
sfga_220
sfga_220
The next thing is to take each line in result_instances.txt, obtain full name from man_exist_instances.txt to produce final file_mail.txt.
Last request is to attach the file file_mail.txt to an email and send it to usera.
Here is my attempt
Code:
#!/bin/ksh
#
# Script Name: chk_eventmon.sh
#
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
`ps -ef | grep -v grep | grep sp_eventmon | cut -c123-130 > sys_exist_instances.txt`
#
`diff <(cut -c1-8 sys_exist_instances.txt| sort) <(sort man_exist_instances.txt| cut -c1-8) | grep "<" | cut -c3- > result_instances.txt`
i=0
patterns=`cat result_instances.txt`
values=[cat man_exist_instances.txt]
for pattern in ${patterns}
do
cat -n ${values[i]} | grep $pattern >> file_mail.txt
((i++))
done
mailx -s "SP Configuration Processes(SPCP)" usera@a.com<<EOM
Please evaluate the reason for the cracsh and restart echo "$(cat \$file_mail.txt)" monitoring using the follwoing example:
nohup ./sp_eventmon -s '-u2200_sfga' -t 30 -p var2200_sfga -m /dev/null &
EOM
Howevern when I execute above, I am getting:
./chk_eventmon_new.sh[25]: man_exist_instances.txt]:
However I do have man_exist_instances.txt
-rwxrwxr-x 1 oracle dba 180 Mar 30 16:45 man_exist_instances.txt
-rw-r--r-- 1 oracle dba 0 Mar 31 11:01 file_mail.txt
-rwxr-x--- 1 oracle dba 1337 Mar 31 11:58 chk_eventmon_new.sh
-rw-r--r-- 1 oracle dba 180 Mar 31 12:09 sys_exist_instances.txt
-rw-r--r-- 1 oracle dba 54 Mar 31 12:09 result_instances.txt
Please help