LinuxQuestions.org
Register a domain and help support LQ
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, 11: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, 07:03 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

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

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:24 PM
shell script to find data that's all in one line wattz Programming 5 07-10-2008 05:48 PM
script to find out time taken to transfer a file aeby Linux - Networking 1 05-09-2007 06:29 AM
how do i find which script is taking up my cpu time? Pete Dogg Linux - Software 4 07-23-2004 07:35 PM
Find files based on time. FinalFantasy Linux - Software 4 05-21-2004 08:25 PM


All times are GMT -5. The time now is 03:56 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration