Shell / Perl script to constantly comb a folder for new files & make copies of the new files

http://www.experts-exchange.com/questions/28922803/Windows-batch-powershell-VB-scripts-to-constantly-comb-a-folder-for-new-files-make-copies-of-the-new-files.html

Refer to above EE link.  I have a similar requirement for RHEL 5/6 & Solaris as well, so
will need Shell / Perl scripts or any other solutions
sunhuxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
are you using qlemo's example, you can use a shell script that will use find -newer reference_file

#!/bin/sh
Quarantine='path_to_quarantine'
Analysis='path_to_analysis'
Root_path='path_of_operation'
if test ! -f "$Root_path/First_run" ; then
    cp -r "$Quarantine/*" "$Analysis"
    touch "$Root_path/First_run"
    touch "$Root_path/last_run"
    exit;
fi
find $Quarantine -newer "$Root_path/last_run" -exec cp {} "$Analysis/" \;
touch "$Root_path/last_run"

Open in new window


the above will deal with copying the quarantined items to the analysis destination without verification if the same file was previously quarantined/analysed...

the encryption what software are you considering for this?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunhuxAuthor Commented:
The encryption software is from an AV product called qdecrypt which
encrypts infected files to make them harmless.

Yes, I'm looking at Qlemo scripts but just posted an update: if only
Qlemo's script track for the last date/time the script last stop/went
down, that will be perfect
arnoldCommented:
You could add logging events that would write out to a file or a DB that the script ran, and finished......

In the above script echo $(date "%b-%d-%Y %H:%M:%s") started/stopped >> record_file

.....
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

sunhuxAuthor Commented:
Or is there something you could add to the script that
will detect an "exit" or the script being killed like
(in the days I was doing VMS DCL scripting):

on error perform ...
on fatal_error perform ...
arnoldCommented:
In a shell script you would use trap to detect signals and act accordingly.

You need to provide more context to the conditions, do not know VMS.
Adding logic to test conditions .....
nociSoftware EngineerCommented:
then there is the incron deamon, which can act on events like creation of a new file in a directory etc.
http://incron.aiken.cz/
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.