Using mail in awk

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using mail in awk
# 1  
Old 07-29-2009
Using mail in awk

I'm having a bit of trouble using the mail command within awk. I'm sending the contents of the body through a pipe like so:
wget -qO- | awk -v oldprice=`cat pricefile` '
    /<b class="price">/ {
    print "The old price is: " oldprice
    retrievedprice = substr($0,2)
    print "The retrieved price is: " retrievedprice

    if (retrievedprice ~ oldprice) {
        print "The price is the same"
        print "The price is not the same"
        print "Old price: $" oldprice "\n New price: $" retrievedprice | "mail -s "The Price Has Changed" username"
        print retrievedprice > "pricefile"

but when I attempt to run the shellscript, It does not appear to see the subject and assumes the username is the subject, so it asks for the recipients. Is it possible to use mail like this? When I use mail without a subject line it works fine.
# 2  
Old 07-30-2009

Did you try escaping the quotes around the subject?

"mail -s \"The Price Has Changed\" username"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. Shell Programming and Scripting

UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file

Greetings Experts, I am on AIX using ksh; I am processing the input files and generating a awk_output.txt file using AWK. By reading that awk_output.txt file, I am building a output.html file which is cat and then fed to /usr/sbin/sendmail .When the shell script is triggered through command... (2 Replies)
Discussion started by: chill3chee
2 Replies

3. Shell Programming and Scripting

awk command with if & mail

Hi Experts, I want to check in table that if third column value is "bhu" & if it is greater than 500 it will send mail other wise there will be no mail. but as per my script mails are still coming even value is below 500 with one blank mail(without any content) with subject line"test mail". I... (12 Replies)
Discussion started by: dravi_laxmi
12 Replies

4. Shell Programming and Scripting

Awk: from two file create a mail with attached error

Hi. My name is Mirko I have two file. File 1: File 2: error 08 ffff test error 05 ffff test error 11 ffff test error 65 ffff test error 55 ffff test Examples I would like to send a mail... (2 Replies)
Discussion started by: Gionfalco01
2 Replies

5. Shell Programming and Scripting

Checking postfix mail log with AWK

Hello, Few days ago I found a person checking his mail log by AWK. But unfortunately I forget to take the command from him. Today I got to need that command badly. Here is a reference. When I check from my mail log like this it will not show me the details. grep "from=<>"... (2 Replies)
Discussion started by: rinti
2 Replies

6. Shell Programming and Scripting

awk search file then pipe to mail

I need to write a script to search a static file (file1) in the form Name Email tim bob and then mail them another file (file2) that is input from the command line. The command line would be: script.awk who file2 subject and the result would be mail -s subject who... (2 Replies)
Discussion started by: tfxobrien
2 Replies

7. Linux

awk filter & Auto gen Mail

hi experts 2012-01-30 10:30:01:812 "y" "NA" "30/01/2012 10:30:01:154 AM" 2012-01-30 10:33:46:342 "y" "NA" "30/01/2012 10:33:45:752 AM" 2012-01-30 10:41:11:148 "n" "200" "30/01/2012 10:41:10:558 AM" 2012-01-30 10:44:48:049 "y" "NA" ... (7 Replies)
Discussion started by: nith_anandan
7 Replies

8. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

9. Shell Programming and Scripting

Mail from awk

Hi, I need to write a single line command which will check whether input variable is 0 or 1. if it is 0 then it should send a mail without attachment else it should send mail with attachment. I have to write in single line command. is there any way in awk? Please help me.. Any help on... (0 Replies)
Discussion started by: smr_rashmy
0 Replies

10. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies
Login or Register to Ask a Question