![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I need to write a shell script. | lakshmanrk | Shell Programming and Scripting | 6 | 06-20-2007 07:00 AM |
| please Write a shell script | rvrao77 | Shell Programming and Scripting | 6 | 11-16-2006 10:16 AM |
| need help to write shell script | getdpg | Shell Programming and Scripting | 0 | 04-10-2006 11:30 AM |
| Help needed to write a shell script! | sreedharsn | Shell Programming and Scripting | 3 | 10-11-2005 01:21 PM |
| Shell Script for Beginner | aaron_fong | Shell Programming and Scripting | 3 | 07-18-2005 03:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Beginner trying to write a shell script!
Dear All,
I'm trying to write a shell script that continously checks a certain folder. When a file is placed in the directory securely copies the file to another server. I've got the secure copying working, but I don't know how to contiously check a directory for a new file and then use that file to scp. (The files contain a date & timestamp within the file name) Any ideas??? Thanks, A Complete Novice |
|
|||||
|
Here is one possible solution: Code:
while true; do
sleep 1
if [ -f /path/to/some/file ]; then
# Take some action
fi
done
After reading RTM's post, you might want to up the time to 10 seconds, or 60 seconds or whatever is reasonable. 1 second is probably to tight of a loop. |
|
||||
|
You can start a script from the cron e.g. every 1 minute or you write a script with is running for ever with a sleep in it (eg. sleep 60, means a sleep for 60 sec).
eg. #!/bin/csh foreach FILE (`find /<your path>/ -newer LastCheck -print`) scp /<your path>/ $FILE /<new path>/$file ...... maybe some more code ...... end touch LastCheck exit To initialize this way you need to create the 'LastCheck' the first time by hand by `touch LastCheck` every time you run this script it copies all files who are newer then the file LAstCheck to the new location See also the find man page: http://docs.sun.com/?q=find&p=/doc/8...9vek55d&a=view |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|