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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending e-mail of record counts in 3 or more files
# 1  
Old 10-28-2010
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:

Code:
/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:
Code:
./sqlldrclaims_test1.sh[44]: 2000,:  not found
./sqlldrclaims_test1.sh[45]: 10000,:  not found
./sqlldrclaims_test1.sh[46]: 10000:  not found


Last edited by Franklin52; 10-28-2010 at 02:19 PM.. Reason: Please use code tags
# 2  
Old 10-28-2010
The problem is here:
Code:
( echo 'CONDITION

Should be:
Code:
( 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").
# 3  
Old 10-28-2010
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?
# 4  
Old 11-01-2010
Quote:
( echo "'CONDITION
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 .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove duplicated records and update last line record counts

Hi Gurus, I need to remove duplicate line in file and update TRAILER (last line) record count. the file is comma delimited, field 2 is key to identify duplicated record. I can use below command to remove duplicated. but don't know how to replace last line 2nd field to new count. awk -F","... (11 Replies)
Discussion started by: green_k
11 Replies

2. UNIX for Beginners Questions & Answers

Sending Excel Files as attachment using Mail

Hie, I need to attach an .xlsx file as an attachment to a mail. I have used the mail option but i dont think there is anything for attachment. Can you show me how else can i do it? I am not allowed to install mutt since it is a workplace and they have their restrictions. And its a Bash Shell (2 Replies)
Discussion started by: barryallen
2 Replies

3. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

4. Shell Programming and Scripting

Searching for files and sending mail

Hi, I want a script that can perform the following tasks, 1)Open command prompt and navigate to certain path (for eg: C:\Programs\) and then execute the below command on a daily basis, list -C <client name> -t 13 -l -R -s <previous_day> /D > D:\Prgrams\list_currentdate.txt Note: There... (2 Replies)
Discussion started by: cratercrabs
2 Replies

5. Shell Programming and Scripting

New file should store all the 7 existing filenames and their record counts and ftp th

Hi, I need help regarding below concern. There is a script and it has 7 existing files(in a path say,. usr/appl/temp/file1.txt) and I need to create one new blank file say “file_count.txt” in the same script itself. Then the new file <file_count.txt> should store all the 7 filenames and... (1 Reply)
Discussion started by: pr293
1 Replies

6. UNIX for Dummies Questions & Answers

Hardcoding & Record counts in a file

HI , I am having a huge comma delimiter file, I have to append the following four lines before the starting of the file through a shell script. FILE NAME = TEST_LOAD DATETIME = CURRENT DATE TIME LOAD DATE = CURRENT DATE RECORD COUNT = TOTAL RECORDS IN FILE Source data 1,2,3,4,5,6,7... (7 Replies)
Discussion started by: shruthidwh
7 Replies

7. Shell Programming and Scripting

sending multiple files along with mail message using uuencode

Hi, I have a requirement to send a mail with multiple files attached to it and along with the text message in the mail. I am trying sumthing like below but it only sends me the text message and no files attached to the mail. ---------------------------------------- ( uuencode file1... (1 Reply)
Discussion started by: sachinkl
1 Replies

8. Shell Programming and Scripting

Stop sending mail after certain number of mail

Hi guys... I am busy writing a script to notify me via an mail if my application is down. I have done that. Now I want this script to stop sending mails after five mails were sent but the script should keep on checking the application. When the application is up again that count should be... (5 Replies)
Discussion started by: Phuti
5 Replies

9. Shell Programming and Scripting

Get counts for multiple files

How do get the counts by excluding header and tailer. wc -l customer_data*.0826 31 customer_data_1.0826 57 customer_data_2.0826 456 customer_data_3.0826 668 customer_data_4.0826 789 customer_data_5.0826 2344 customer_data_6.0826 13457 customer_data_7.0826... (6 Replies)
Discussion started by: zooby
6 Replies

10. UNIX for Dummies Questions & Answers

sending a mail to a mail client

Hi everyone! I'm trying to create a database monitoring script that reads an alert file and sends an error message if it can 'grep' a particular string. Is there a way to send this message to a mail client using SMTP? Even better, is there any place on this site that has these kinds of... (5 Replies)
Discussion started by: solaris73
5 Replies
Login or Register to Ask a Question