Hi Experts
I will have be having 3 types of files in directory
file1_p0_date
file1_p1_date
file1_p2_date
As soon as it sees any of the files it needs to kick off another process and also would need the file name
For this I am creating a file watcher script which will look for file1* My questions are :
1) how to get the file name ?
2) After it gets the first file and Kicks off the process will I have to delete the file or move it to another directory so that it does not pick the same again?
Thanks for the help
This doesn't check if the file transfer has completed etc. But should be enough to get you started?
#!/bin/ksh
if [ ! -d .done ] ; then
mkdir .done
fi
if [ ! -d .error ] ; then
mkdir .error
fi
while true
do
file_list=$( ls file1_* 2>/dev/null )
if [ -n "$file_list" ] ; then
for file_name in $file_list ; do
echo "Processing $file_name"
#run some command...
if [ $? -eq 0 ] ; then
mv $file_name .done/ # Assume .done dir
else
mv $file_name .error/ # Assume .error dir
fi
done
fi
sleep 2
done
Thanks a lot for your prompt reply Rakesh !!
Will try this out
Thanks
Bob