Hi All
I have a FTP script which FTPs few files into an user folder. I intend to keep track of the folder size before FTP and after FTP and print that once the FTP script is run (a kind of comparison, "Before FTP, "After FTP").
I decided to use kron shells to accomplish this.
Code:
#! /bin/ksh
analyse_folders_pre() {
# List of directories to check.
dirNames[0]='bin'
dirPath[0]='/home/user1/bin'
dirNoFilesPre[0]=$(ls ${dirPath[0]} | wc -l | awk '{print $1}')
idx=0
while [ $idx -ne 1 ]
do
tempSize=0
dirFileSizePre[$idx]=0
dirSize=0
for i in $(ls ${dirPath[0]})
do
tempSize=$( ls -l $i | awk '{print $5}')
((dirSize=dirSize+tempSize))
done
dirFileSizePre[$idx]=$dirSize
((idx = idx+1))
done
} ### End of analyse_pack_rel_pre
### Main Script Starts here ###
# List of directories to check.
dirNames[0]='bin'
export dirNames
dirPath[0]=''
export dirPath
dirNoFilesPre[0]=0
export dirNoFilesPre
dirNoFilesPost[0]=0
export dirNoFilesPost
analyse_folders_pre
### Script to FTP
ftp_files
analyse_folders_post
i=0
while [ $i -ne 1 ]
do
echo ${dirNoFilesPre[$i]}
echo ${dirFileSizePre[$i]}
echo ${dirNoFilesPost[$i]}
echo ${dirFileSizePost[$i]}
((i=i+1))
done
But, I am getting the following error.
syntax error at line 8: `dirNoFilesPre[0]=$' unexpected
What might be wrong? Is there any better way to do it?