Help: script to monitor incoming files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help: script to monitor incoming files
# 1  
Old 07-08-2009
Help: script to monitor incoming files

I have 20 or so files that are ftp'd each day to a particular directory. I want to create a script that will tell me if any of these files fails to arrive or if any additional files arrive. I'm thinking I'd have a list of file names that should arrive each day, and the script would check each days files against this list. Anyone got any bright ideas!? Thanks!
# 2  
Old 07-08-2009
If you are on Linux you can use inotify to trigger script action every time a file arrives.
Otherwise, you will l have to run your job very late in the day and compare filenames to a list of expected names. Here is a simple example to start with:
filelist - list of files like
file.txt
pdq.lis

This assumes the new files are eventually moved or renamed
Code:
ls -1 > currentfiles
awk 'FILENAME=="filelist" {arr[$0]++}
       FILENAME=="currentfiles" { if (! $0 in arr) {print "new file: " $0 } else {arr[$0]++}}
       END {for (file in arr) {if(arr[file]==1) {print arr[file] " not found"}}   }   
       '   filelist  currentfiles

# 3  
Old 07-09-2009
Thankyou for that, has got me thinking a bit more!
The filenames that come in each day include the date, eg abcdef.20090708.gz.

So I think I will have to compare part of the file names, rather than look for an exact match. Perhaps I can have a file containing a list of strings (which will be the filenames expected to be rec'd each day minus the date part). Then a file listing all files rec'd on a particular day can be checked to see that each line contains one of these strings.

The newly received files are not renamed or moved, they just stack up in a folder, but since the filename contains the date they are of course unqiue names.

Any thoughts gratefully received!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to monitor the changes on files

Hello all, I'm planning to write a script to monitor the changes on configuration files on my application server, i have around 50 properties files which really crucial for the application to perform well but we have a challenge here is that all the application team (development, testing and... (2 Replies)
Discussion started by: Mahesh_RPM
2 Replies

2. Homework & Coursework Questions

Need shell script to monitor files

Hi Experts, I am not good in writing script. Just stared. I am looking for shell script to check following parameters. 1) Number of files on remote Linux SUSE server.- Any directory and sub directory. 2) I should define number of files in script. Files should be variable. 3) Age of the... (2 Replies)
Discussion started by: ApmPerfMonitor
2 Replies

3. Homework & Coursework Questions

shell script that can create, monitor the log files and report the issues for matching pattern

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write an automated shell program(s) that can create, monitor the log files and report the issues for matching... (0 Replies)
Discussion started by: itian2010
0 Replies

4. Shell Programming and Scripting

Shell Script to monitor folder and upload found files via FTP

Hi everyone! I'm in a need of a shell script that search for all files in a folder, move all those files to a temp folder, and upload those files via FTP. When the file transfer via FTP completes successfully, the file is moved to a completed folder. In case any of those files fails, the file... (4 Replies)
Discussion started by: pulsorock
4 Replies

5. UNIX for Dummies Questions & Answers

Monitor files

I have just started UNIX administration..I want to monitor files with a specific extensions.. ie, I want to monitor .doc or .DOC files created in particular directory..The script should display (every minute) a list of those filenames created after the previous display. (1 Reply)
Discussion started by: aadi_uni
1 Replies

6. Shell Programming and Scripting

Script to number incoming files

Hey guys, I am working on a Cshell script and I am stuck on this one part. I need to be able to copy in files to my directory but give them different names so they don't overwrite each other. For example, my folder already contains FILE.1 I want my script to name the next file copied over... (5 Replies)
Discussion started by: hootdocta5
5 Replies

7. Shell Programming and Scripting

script to monitor files in a directory and sending the alert

Hi All, We are having important config files in an directory which was accessable by all /auto/config/Testbed/>ls config1.intial config2.intial config3.inital often we find that some of the lines are missing in config files, we doubt if some one is removing. I would like to write... (0 Replies)
Discussion started by: shellscripter
0 Replies

8. Shell Programming and Scripting

Detecting incoming files without busy polling

Hello, I'd like to handle incoming (uploaded) files from a shell script, ideally without busy polling / waiting (e.g. running a cron task every 15'). Is there a command that would just sleep until a new entry has been created in a directory, allowing scripts such as the following: while... (9 Replies)
Discussion started by: baldyeti
9 Replies

9. UNIX for Dummies Questions & Answers

run a script from incoming email

hi I have a bit of a problem i need help with. I have a script that runs no problems when i run it manually. as soon as i stick in tester: /app/scripts/run.pl into /etc/aliases & try to run it by sending a mail it doesnt work. the output files are owned by daemon, which i dont like & think... (7 Replies)
Discussion started by: jojo77
7 Replies

10. Shell Programming and Scripting

need help doing a script to monitor if files are go through

I am trying to do a shell script to check a folder and see if files are passing through. Now if a file did not pass through in the last 1 hour send an email. ftp----------> folder to monitor ----------->ftp Now the script that moves the file runs every sec in cron, so i do not know if i... (0 Replies)
Discussion started by: jonathan184
0 Replies
Login or Register to Ask a Question