LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2010, 10:33 AM   #1
ccampbell@etcc.com
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Rep: Reputation: 0
Script to find files by data and time


This is what I’m trying to do…
We have a script that FTP files 3 times a day, once ant 02:30, 04:00 and 13:00. Once the process runs it puts a copy of the file sent in the processed folder. What I’m trying to do is check to see if the files are there and if not send an alert /email.
The file names are IVF_20100806_*.150, PLAZ_ 20100806_*.151, TRAN_20100806_*.152 and TRAN_20100806_*.151

This is what I have

#!/bin/ksh
#
. ${HOME}/.bash_profile

check_file()
{
pattern="${1}_`date '+%Y%m%d'`_${3}"

echo "Checking ${pattern}"

found="NO"
for x in `ls /home/oracle/INCOMING/PROCESSED/${pattern} 2>/dev/null`
do
echo "Found ${x}"

echo "Is it recent?"
chk=`./is_recent ${x} ${3}`
echo ${chk}

if [ "${chk}" = "YES" ]
then
found="YES"
fi
done

if [ "${found}" = "NO" ]
then
echo "Did not receive ${1} file, sending an e-mail to XXX@XXX.com"
mailx -s"Did not receive ${1} file" XXX@XXX.com < /dev/null
fi
}

check_file TRAN "*151" 1
check_file TRAN "*152" 1
check_file IVF "*" 1
# check_file POSI "*" 1
# check_file DIF "*" 1
check_file PLAZ "*" 1
 
Old 08-06-2010, 06:03 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Well, good. So what's the problem?

Also, please use [code][/code] tags around your code, to preserve formatting and improve readability.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with a shell script that data parses /usr/bin/time Ryzol Programming 1 08-04-2008 04:24 PM
shell script to find data that's all in one line wattz Programming 5 07-10-2008 04:48 PM
script to find out time taken to transfer a file aeby Linux - Networking 1 05-09-2007 05:29 AM
how do i find which script is taking up my cpu time? Pete Dogg Linux - Software 4 07-23-2004 06:35 PM
Find files based on time. FinalFantasy Linux - Software 4 05-21-2004 07:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration