Sending e-mail of record counts in 3 or more files

I am trying to load data into 3 tables simultaneously (which is working fine). Then when loaded, it should count the total number of records in all the 3 input files and send an e-mail to the user.

The script is working fine, as far as loading all the 3 input files into the database tables, but i am not able to send e-mail.

Appreciate any help, with the script.

************************
The shell script is:

/usr/local/pl/util_scripts/perlencrypt.pl -k /export/home/oracle/secure/ealgorithm -d /sdr1/system/$pwd_file | sqlldr $userName control=/space/dbexport/
PHR/control/condition.ctl log=/space/dbexport/PHR/log/condition-`date +%Y%m%d`.log bad=/space/dbexport/PHR/bad/condition-`date +%Y%m%d`.bad
 
/usr/local/pl/util_scripts/perlencrypt.pl -k /export/home/oracle/secure/ealgorithm -d /sdr1/system/$pwd_file | sqlldr $userName control=/space/dbexport/
PHR/control/encounter.ctl log=/space/dbexport/PHR/log/encounter-`date +%Y%m%d`.log bad=/space/dbexport/PHR/bad/encounter-`date +%Y%m%d`.bad
 
/usr/local/pl/util_scripts/perlencrypt.pl -k /export/home/oracle/secure/ealgorithm -d /sdr1/system/$pwd_file | sqlldr $userName control=/space/dbexport/
PHR/control/procedure.ctl log=/space/dbexport/PHR/log/procedure-`date +%Y%m%d`.log bad=/space/dbexport/PHR/bad/procedure-`date +%Y%m%d`.bad
 
( echo 'CONDITION, ENCOUNTER & PROCEDURE LOAD PROCESS FINISHED SUCCESSFULLY', The total records loaded into the tables are:
$( wc -l < /space/dbexport/PHR/data/conditionExport_test.csv),
$( wc -l < /space/dbexport/PHR/data/encounterExport.csv),
$( wc -l < /space/dbexport/PHR/data/procedureExport.csv) $logfile $basename ) | mailx -s "$subject" "$to" msrblr@gmail.com

The error that i am getting is:

./sqlldrclaims_test1.sh[44]: 2000,:  not found
./sqlldrclaims_test1.sh[45]: 10000,:  not found
./sqlldrclaims_test1.sh[46]: 10000:  not found

The problem is here:

( echo 'CONDITION

Should be:

( echo "'CONDITION

This opening double quotes will protect the newlines in your multi-line echo statement. I can't see where the closing double quote will go - only that it will be on the same line as the "mailx" command. Depends what you want the mail message to look like.
Without the double quote each continuation line is being presented to Shell to execute (hence the "not found").

Hi,
I tried running the script with "CONDITION , but its still the same.

Script:

( echo "CONDITION, ENCOUNTER & PROCEDURE LOAD PROCESS FINISHED SUCCESSFULLY", The total records loaded into the tables are:
$( wc -l < /space/dbexport/PHR/data/conditionExport_test.csv);
$( wc -l < /space/dbexport/PHR/data/encounterExport.csv);
$( wc -l < /space/dbexport/PHR/data/procedureExport.csv) ; $logfile $basename ) | mailx -s "$subject" "$to" id11355@noridian.com

Error:

Commit point reached - logical record count 10000
./sqlldrclaims_test1.sh[44]: 2000: not found
./sqlldrclaims_test1.sh[45]: 10000: not found
./sqlldrclaims_test1.sh[46]: 10000: not found

Is there any other alternative for this?

Note that the double quote is before the single quote (not instead of the single quote).
Imho The matching closing double quote should be three lines later. Just after $basename .