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- http://cs.actx.edu/~craddock/unix2/lab11 | awk -v oldprice=`cat pricefile` '
/<b class="price">/ {
print "The old price is: " oldprice
getline
retrievedprice = substr($0,2)
print "The retrieved price is: " retrievedprice
if (retrievedprice ~ oldprice) {
print "The price is the same"
}
else{
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.