Solved

How to print cents symbol ¢, double quotes, and bold-ed text in e-mails produced under Linux from an AWK script

Posted on 2007-03-31
13
23,535 Views
Last Modified: 2013-12-26
I'm at a total loss with this one.

This is an AWK scripting question.  If someone can suggest a Perl solution, I'd take that one, too.

Of course I've already tried entering Alt-0162 and a variety of single quotings, double quotings, ticks, double-double quotings, double-single quotings, etc.  But, there must be some simple way to do this that I just haven't tried or know about.
 
Here's the script I want to use to inform our customers about a 5¢ price increase (note the 5¢).  It's important to use the cents symbol, so the perception is that the increase is VERY SMALL. 5¢ is just a "nickel", after all...

========== Script begins here ==========

BEGIN { "date" | getline d
split(d,darr," ")
dtstamp=sprintf("%s %s %s %s\n",darr[1],darr[2],darr[3],darr[6])
}

{

{ thismail = sprintf("echo \"%s\n\nDear %s,\n\nAfter six years of
stable prices, the cost of ink has increased to a point where we can
no longer absorb it. So, we will be increasing the cost of our
premium inks by 5[the cents symbol needs to go here] per pint,
effective May 1, 2007.\n\nWe realize that this may seem like a very
small increase, but over our many customers, and the many, many
gallons shipped, it should cover the increases without greatly
affecting your core business.\n\nThank you for your time.\n\nJerry
Gilels and\nThe TelePrint Operations Team\nCustomer Service Hours:
9am-9pm Mon-Sun (CST)\n\" | mail %s -s\"[Subject goes here]\"",dtstamp,
$5)

}
system(thismail)
}

========== Script ends here ==========

Also, how can I display the double quotes (") symbol and bold-ed text in the same e-mail? I can't get them to work either.

Thanks in advance for your help.

Jerry Gilels
Dallas, TX
214-526-9692
0
Comment
Question by:jerry_gilels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +4
13 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18829159
{ thismail = sprintf("echo \"%s\n\nDear %s,\n\nAfter six years of stable prices, the cost of ink has increased to a point where we can no longer absorb it. So, we will be increasing the cost of our premium inks by 5¢ per pint, effective May 1, 2007.\n\nWe realize that this may seem like a very small increase, but over our many customers, and the many, many gallons shipped, it should cover the increases without greatly affecting your core business.\n\nThank you for your time.\n\nJerry Gilels and\nThe TelePrint Operations Team\nCustomer Service Hours: 9am-9pm Mon-Sun (CST)\n\" | mail %s -s\"[Subject goes here]\"",dtstamp, $5, $5)

}
0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 18830909
You can get the cents symbol (¢) in Perl with chr(162), as in:

#!/usr/bin/perl -w
use strict;

my $cents = chr(162);

print "$cents";

If you need the latin capital letter A with circumflex (Â), it's chr(194).
0
 
LVL 84

Expert Comment

by:ozo
ID: 18831315
you could also use "\242" in either Perl or awk
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 18832329
cent symbol for which character set?

Are you aware that your script has no control over the mail client's character set?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18833770
It would be more reliable to generate a PDF or HTML email.
0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 18835406
I agree with Tintin -- I think HTML email is the way to go here...

The cents symbol, in HTML, is (predictably enough):

¢
0
 

Author Comment

by:jerry_gilels
ID: 18836525
I cannot use HTML.  Not everyone has HTML turned on (me, for example).

So, I got my solution elsewhere.

After several (actually many) incorrrect answers, I contacted another developer (from another web site) and actually WORKED through the problem with him on the phone.

Eventually, someone did come up with PART of the solution (but, not the whole solution) here.  And, it was too late.

The answer:

BEGIN { "date" | getline d
         split(d,darr," ")
         dtstamp=sprintf("%s %s %s %s\n",darr[1],darr[2],darr[3],darr[6])
}

{ thismail = sprintf("echo -e \"%s\n\n \242  \n\n...

}

}
system(thismail)
}

No one got the "echo -e", which is the only thing that makes the octal code work.

Zero Points.

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18838063
and how does this display if you have set your environment variable LANG to UTF-8?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 19313715
I don't see a reason for a refund ...
0
 
LVL 20

Expert Comment

by:Venabili
ID: 19315288
The asker posted the solution that worked for him.
May not be the best one for the way the question was looking like but it worked for him
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 19315932
agreed
0
 

Accepted Solution

by:
AnnieMod earned 0 total points
ID: 19387322
PAQed with points refunded (250)

AnnieMod
Cleanup Admin
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
NotAlone Challenge 20 88
Annoying "thing" blocks my view 4 133
Control Number of Log Files -Perl 7 94
Bartender label printing - switch on and off graphics 3 77
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question