Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I have a complex shell scripting requirement.
1. I need to fetch last 7 days archived log files by querying database.
2.Then I have to compare the file names i got from querying oracle table with the file name existing in the file system directory. If anything is missing i need to send mail to DBA team.
3. If everything is fine. I need to send the count of files that are archieved for the past 7 days.
4. I will have to schedule it to run on monday morning so that I can report the summary for the last week.
I can fetch list of file names from oracle tables and put it in a temp file. but i am wondering how to compare this list with list of file system files. I need to compare with the name of the file.
If you need more details, let me know
Can anyone help me?Thanks and regards
Suresh H Thopaiah
sureshht@yahoo.com

OK. Given a sample file that looks like this:
Input file name "files.in"
cygwin.tic
dhcp.ksh
gethost.exe
junk.html
junk1.html
junk3.html
keys.txt
license.txt
misc.txt
numbers.txt
output.lines
trchkid.h
united.txtAnd I want to find out if these files exist in the /home/Administrator directory, I'd do this:
#!/bin/ksh
Directory=/home/Administrator
exec 3<files.in
while read -u3 filename
do
if [[ -f $Directory/$filename ]]
then
print "File found"
else
print "File not found"
fi
done

Hi,
Thanks for your reply.
I am pulling list of archivelog files from database to a tempfile1.Also I am pulling directory archivelog path from database and putting in tempfile2.
I want to go to the directory path (cd to) in the tempfile2. say tempfile2 has the path '/oracle/app/oracle/admin/sepmbx1/archive'. I want to go to this path and pump the list of files in the directory to a tempfile3.
Then I want to compare the existance of entries from tempfile1 in the tempfile2.
I dont know whether i am clear on what I want. Please let me know if any confusion
Thanks and regards
Suresh
sureshht

Got several issues you need to resolve. Do the file names extracted from the database have a relative or absolute path?
If they have an absolute path, they should have the form:
/mydir/filename
and if they have an relative path then they'll have the form:
./mydir/filename
and finally, do they contain just a file name such as
myfile
Let me know and I'll cook something up for you.

I solved my issue with another one i filed:
'comparing 2 files with shell script' in this forum.Thanks for your assistance.
Suresh
sureshht

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |