after editing my script I would shortly like to explain what i want to do:
- Check if files are in Folder
- Look at begin of file name
- search for file less than 1 hour old
- take the file and do sqlldr ..if this succeeds move file to an other folder ...if not send mail
This is my Script, can someone please tell me if this is going to work? I am not sure about the syntax and also not sure if nr. 3 and 4. send mail works like this.
#!/bin/sh
#check if files are in folder
declare -a arrCSV #create array
for file in *.csv
do
arrCSV=("${CSV[@]}" "$file")
done
shopt -s nullglob
for file in read*.csv; do
#run on all files starting with "read" and ending with ".csv"
for find $LOCATION -name $file -type f -mmin -60 do
if
sqlldr read*.csv
then mv "$file" "$HOME/fail/" ;
else{ echo "Failed to load" | mail -s "FAIL" [email protected]}
done
done
for file in write*.csv; do
#run on all files starting with "write" and ending with ".csv"
for find $LOCATION -name $file -type f -mmin -60 do
if
sqlldr write*.csv
then mv "$filen" "$HOME/unisem/fail/" ;
else { echo "Failed to load 2" | mail -s "FAIL" [email protected]}
done
done
You don't need an array if the read... and write... files can be processed in any order: