Sponsored Content
Full Discussion: script to monitor directory
Top Forums Shell Programming and Scripting script to monitor directory Post 302227026 by otheus on Wednesday 20th of August 2008 11:52:32 AM
Old 08-20-2008
Classic mailbox problem. One problem you have is: how do you know the files are really there, as opposed to partly there? Also, after you sftp them out, do you remove them?

Without addressing these problems (above), here's a simple script:
Code:
MAILBOX=some_directory
seq=0
while true; do 
   let seq=seq+1   # this might be bash specific
   if  /bin/ls -1 $MAILBOX | grep ^ ; then
      # make sure incoming files aren't mixed up with files-to-be-processed
      mv $MAILBOX $MAILBOX.$seq
      mkdir $MAILBOX
      # your function
      sftp_this_directory $MAILBOX.$seq
      # clean up 
      rm -rf $MAILBOX.$seq
   fi

   sleep 300 # wait 5 minutes
done


Last edited by otheus; 08-20-2008 at 12:55 PM.. Reason: sequence fix
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Hep with script to monitor directory

Hello, I am a newbie who is attempting to write a script to monitor a directory for a set of 3 files that I am expecting to get ftp'd. Occasionally, we suspend operations for maintenance etc. but we still get the files so there can be more than 1 set. If there is more than 1 set, I would like... (2 Replies)
Discussion started by: cmf00186
2 Replies

2. 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

3. Shell Programming and Scripting

Monitor capacity of directory

Good morning. I have been attempting to find a way to monitor the capacity of a directory so that when it reaches 80% or higher I can send an event. I was able to find a script that does this for the whole drive by I can not seem to figure out how to do this for just a single directory. ... (1 Reply)
Discussion started by: LRoberts
1 Replies

4. AIX

monitor directory events

I'm am looking for a cheap way to trigger a script when a new file is written in a specific directory. AIX 5.3. It is a production system, so no kernel patching (i.e. inotify). Filemon and audtiing are too expensive. Thanks in advance. (2 Replies)
Discussion started by: pbillast
2 Replies

5. UNIX for Dummies Questions & Answers

Monitor directory and email

Hello all, Can anyone please guide / help me in the following task.... I have a directory where some external users will upload pdf files. The filename of these pdf will be of a particular format (<id>-<first name>_<last name>_<some number>.pdf) I want to make a script such that it takes... (6 Replies)
Discussion started by: dhawalkv
6 Replies

6. Shell Programming and Scripting

Directory Monitor in KSh

Hi, I need to write a directory monitor, i.e. a korn shell script which would Report changes to the directory contents, like: added file1, deleted file2, updated file3 , created subdir (optional)... There is no specific file pattern. So far I have written a little script... (1 Reply)
Discussion started by: olegkon
1 Replies

7. Shell Programming and Scripting

Script to monitor directory size of specific users

Hi, i am new to shell scripts, i need to write a script that can monitor size of directory of specific users. Please help. Thanks, Nitin (2 Replies)
Discussion started by: nicksrulz
2 Replies

8. Shell Programming and Scripting

Shell script to monitor new file in a directory and mail the file content

Hi I am looking for a help in designing a bash script on linux which can do below:- 1) Look in a specific directory for any new files 2) Mail the content of the new file Appreciate any help Regards Neha (5 Replies)
Discussion started by: neha0785
5 Replies

9. Shell Programming and Scripting

awk to monitor size in directory

i'm trying to find the most efficient way to monitor specific files in different directories in one go. /var/log/ /var/app/ /var/db/ each one of these directories can have subdirectories which need to be looked into as well. I want to find any file in this directory that has the name... (7 Replies)
Discussion started by: SkySmart
7 Replies

10. Shell Programming and Scripting

Bash script monitor directory and subdirectories for new pdfs

I need bash script that monitor folders for new pdf files and create xml file for rss feed with newest files on the list. I have some script, but it reports errors. #!/bin/bash SYSDIR="/var/www/html/Intranet" HTTPLINK="http://TYPE.IP.ADDRESS.HERE/pdfs" FEEDTITLE="Najnoviji dokumenti na... (20 Replies)
Discussion started by: markus1981
20 Replies
MBOXGREP(1)						      General Commands Manual						       MBOXGREP(1)

NAME
mboxgrep - displays email messages matching a pattern SYNOPSIS
mboxgrep [OPTIONS] PATTERN [MAILBOX] DESCRIPTION
This manual page refers to mboxgrep version 0.7.9. mboxgrep scans a MAILBOX and displays messages matching PATTERN. If a mailbox name is ommited, or a single dash (-) is given instead, it reads from standard input. It can read mbox folders or output from another mboxgrep process from standard input. mboxgrep understands POSIX regular expressions, as well as Perl compatible regular expressions (if enabled at compile time). MAILBOX can be either a: o mbox folder (either plain or compressed) o MH folder o Gnus nnmh or nnml folder o qmail-style maildir folder OPTIONS
-h, --help Display a help screen and exit. -V, --version Display version and copyright information and exit. -r, --recursive Descend into directories recursively. -E, --extended-regexp PATTERN is an extended regular expression. This is default. -G, --basic-regexp PATTERN is a basic regular expression. -P, --perl-regexp PATTERN is a Perl regular expression. Works only if enabled at compile time. -e, --regexp=PATTERN Use PATTERN as a regular expression. -i, --ignore-case Ignore case distinctions. -v, --invert-match Select messages which don't match PATTERN. -H, --headers Match PATTERN against message headers. -B, --body Match PATTERN against message body. -l, --file-lock=METHOD Select file locking METHOD. METHOD is `fcntl', `flock', or `none'. -nl, --no-file-lock Do not lock files. This option is meaningful only if a mbox folder (see below) is scanned. -c, --count Suppress normal output and print a count of matching messages. -o, --output=FOLDER Suppress normal output and write messages to destination folder FOLDER instead. -p, --pipe=COMMAND Pipe each found message to COMMAND -d, --delete Suppress normal output and delete selected messages instead. Use with caution. -nd, --no-duplicates Ignore duplicate messages. -m, --mailbox-format=TYPE Select input and output mailbox TYPE. TYPE can be either `mbox' (default), `zmbox' (meaning `gzip compressed mbox'), `bz2mbox' (meaning `bzip2 compressed mbox'), `mh', `nnml', `nnmh' or `maildir'. EXAMPLES
o Search $MAIL for messages from Dirty Harry: mboxgrep '^From:.*callahan@homicide.SFPD.gov' $MAIL o Display all messages contained in folder ~/Mail/incoming, except those that appear to originate from AOL: mboxgrep -v 'Received:.*aol.com' ~/Mail/incoming BUGS
Report them to address below. NOTICE
Mboxgrep was alomost completely rewritten since version 0.5.3. Additionally, there was no stable 0.6.x branch between 0.5.3 and 0.7.0. SEE ALSO
grep(1), regex(7), perlre(1), mbox(5), RFC 2822 DEDICATION
Mboxgrep is dedicated in loving memory of Vicky, my cat who died of tumor on Sep 12, 2002. You haven't been long with us, but you gave us a lot of joy and all your big heart that stopped ticking too early. I will never forget you. Sleep well, little friend. URL
http://www.mboxgrep.org/ AUTHOR
Daniel Spiljar <dspiljar@world.std.com> 24 Aug 2003 MBOXGREP(1)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy