![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Auto copy for files from folder to folder upon instant writing | Bashar | UNIX for Advanced & Expert Users | 2 | 08-21-2008 11:44 AM |
| Commercial KVM-based virtual desktop program arrives | iBot | UNIX and Linux RSS News | 0 | 04-29-2008 09:50 PM |
| Ksh Storing Multiple Files and reading each line in each file. | developncode | UNIX for Dummies Questions & Answers | 1 | 04-08-2008 01:44 PM |
| Parse the .txt file for folder name and FTP to the corrsponding folder. | MeganP | Shell Programming and Scripting | 3 | 07-03-2007 10:54 AM |
| grep multiple text files in folder into 1 text file? | coppertone | UNIX for Dummies Questions & Answers | 7 | 08-23-2002 11:50 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
reading a file name as soon as that files arrives into a folder
Hi,
Thanks in Advance.. i have the following requirement, some one please help me.. An unix shell script has to pick up the file name from a folder as soon as that file comes into that folder. Regards, Alo |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
How about using a sleep ?
Code:
#! /bin/sh while true do [ -f /path/to/the/new/file ] && echo "/path/to/the/new/file" #sleep for 1 min sleep 60 done |
|
#3
|
||||
|
||||
|
if time is critical ... use "sleep 1" instead to check every second ...
|
|
#4
|
|||
|
|||
|
If you can have the check done every minute, the most efficient way is probably to schedule it via the crontab utility. Here's what your cron entry could look like:
* * * * * move_file.sh /the_dir/the_file This entry would run a script (move_file.sh) every minute of every day. The script just needs to test the exeistence of the file and do whatever needs to be done with it. HTH Réal |
|
#5
|
|||
|
|||
|
Vino,
Thanks for your post. i m using ksh shell script and tested the following file, #! /bin/ksh while true do [ -f /synchen/dtazv/fhu/sourcedir ] && echo "/synchen/dtazv/fhu/sourcedir" #sleep for 1 min sleep 60 done the following error has been thrown, $ ksh Test2.sh Test2.sh[2]: ^M: not found. Test2.sh[3]: 0403-057 Syntax error at line 8 : `done' is not expected. Please give your advice on this. Regards, Alo |
|
#6
|
||||
|
||||
|
^M character shows you transfered the script from a windows m/c to unix.
Do this.. Code:
dos2unix Test2.sh If it doesnt work try this Code:
#! /bin/ksh while true ; do [ -f /synchen/dtazv/fhu/sourcedir ] && echo "/synchen/dtazv/fhu/sourcedir" #sleep for 1 min sleep 60 done |
|
#7
|
||||
|
||||
|
I tried your code on my machine and it works perfect.
Vino |
||||
| Google The UNIX and Linux Forums |