Sponsored Content
Top Forums Shell Programming and Scripting Building a better mouse trap, or How many lines of code does it take to trap a mouse? Post 302070681 by mph on Thursday 6th of April 2006 03:04:40 PM
Old 04-06-2006
Perderabo,

Quote:
Not sure that I understand. Is this one directory or a directory tree? How the the files get removed? Anyway...
This is a directory tree /ftp. Under this there are the users and their incoming and outgoing directories. Each user has their own directory for security reasons. Our customers don't want their data availible to the wrong vendors.
Files get removed by another daily cron job that finds files older than 10 days. The date can't be trusted as far as how many minutes old they are. So, find works fine for removing old the files. If they're transferred via CIFS it holds the creation date previous to the transfer. That's why I use the -cmin. It seems to work well and uses the access time of the transfer. But I think that's where some files fall through. I had to setup ntp on the server due to clock variations between the server and the clients causing problems with file times. Another reason to use the "find all files and diff them" logic.
Quote:
I would loop through all the files getting name and size (if date cannot be trusted, ignore it). Add name and size to a little database somewhere, timestamping this addition. Or if the entry is present, update size and timestamp. Then loop through database and find entries with old timestamps; process these; remove from database and directory (removal not possible? --- mark as processed in the database.)
This is simular to what (I guess) I was trying to say with the idea I was looking into. That is to say, find all the files under /ftp/*/outgoing and diff them for additions against the file list built 5 minutes ago. Using the diffed file names, the "database" would simply be a temp file containing the name and size. Grep for the file, awk the $NF for the size and compair till they're the same, sleeping for bit between checks to avoid frantic looping. When the run is finished delete the temp database. Removed files won't be an issue, since I'm only looking for added files between runs. If the file reapears, there's usually a good reason for it (corrupted IGES files, etc...) and the vendor should be re-notified.

I hope this makes sense. My fingers are too well connected to my brain.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Mouse wheel...

Hello. I've got round to installing RedHat 7.1, and i have this slight problem. I'm not able to use my mouse wheel. Is this just not possible in RedHat or is there a way to configure my mouse so i can use my mouse wheel. Thank you. (1 Reply)
Discussion started by: Mr-Pixie
1 Replies

2. Linux

Mouse Problems

I just got the other computer working again and i put Fedora Core 2 on it but theres a problem. It wont recongnize my mouse at all. Not in installation or in the actual desktop... it doesnt even know its there. It says No - Mouse.... does anyone know how i can fix this? (4 Replies)
Discussion started by: FordGuy
4 Replies

3. UNIX for Advanced & Expert Users

Indigo mouse

A few years ago i found i the Net a "homework" about how to convert ps2 mouse to Indigo mouse. But i do not save it. Anybody helps me? There are about 10 Indigo mice in all of my country. Thanks in advance (2 Replies)
Discussion started by: mikidimov
2 Replies

4. HP-UX

reset mouse

I have a Belkin KVM switcher, but when I switch from Unix to Windows, then back to Unix, the mouse stops working is there any way to reset the mouse without restarting the workstation? thanks! (0 Replies)
Discussion started by: xRonin
0 Replies

5. UNIX for Dummies Questions & Answers

Changing middle mouse button for pasting to right mouse button in cygwin rxvt

Hi, I'm using rxvt in Cygwin and I'm wondering how to change my mouse bindings from the middle button for pasting to the right button. The main reason why I want to do this is because my laptop doesn't have a middle mouse button. Thanks for any help! (2 Replies)
Discussion started by: sayeo
2 Replies

6. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

7. What is on Your Mind?

Keyboard vs mouse

Which Input device do you use the most ? for me... keyboard ofcourse !! (56 Replies)
Discussion started by: vpraveen84
56 Replies

8. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

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: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies
trap(1) 							   User Commands							   trap(1)

NAME
trap, onintr - shell built-in functions to respond to (hardware) signals SYNOPSIS
sh trap [ argument n [n2...]] csh onintr [-| label] ksh *trap [ arg sig [ sig2...]] DESCRIPTION
sh The trap command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n). (Note: argument is scanned once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number or corresponding symbolic names. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11 (memory fault) produces an error. If argument is absent all trap(s) n are reset to their original values. If argument is the null string this signal is ignored by the shell and by the commands it invokes. If n is 0 the command argument is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. csh onintr controls the action of the shell on interrupts. With no arguments, onintr restores the default action of the shell on interrupts. (The shell terminates shell scripts and returns to the terminal command input level). With the - argument, the shell ignores all inter- rupts. With a label argument, the shell executes a goto label when an interrupt is received or a child process terminates because it was interrupted. ksh trap uses arg as a command to be read and executed when the shell receives signal(s) sig. (Note that arg is scanned once when the trap is set and once when the trap is taken.) Each sig can be given as a number or as the name of the signal. trap commands are executed in order of signal number. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. If arg is omitted or is -, then the trap(s) for each sig are reset to their original values. If arg is the null (the empty string, e.g., "" ) string then this signal is ignored by the shell and by the commands it invokes. If sig is ERR then arg will be executed whenever a command has a non- zero exit status. If sig is DEBUG then arg will be executed after each command. If sig is 0 or EXIT for a trap set outside any function then the command arg is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each signal number. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), exit(1), ksh(1), sh(1), attributes(5) SunOS 5.10 23 Oct 1994 trap(1)
All times are GMT -4. The time now is 04:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy