Operating System - HP-UX
1833594 Members
3800 Online
110061 Solutions
New Discussion

bold and underline words created in kornshell script

 
Richard_115
Frequent Advisor

bold and underline words created in kornshell script

Hello All,
I want to reformat a report written in kornshell that's sent to a file and e-mailed to me to print via my local printer. Is there a way to bold or underline some of the words with in the script?

Any help would be appreciated
Debbie
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: bold and underline words created in kornshell script

Does your e-mail client understand HTML e-mail messages? If so, you could HTML-ize the report.
Michael Tully
Honored Contributor

Re: bold and underline words created in kornshell script

The mormal formatting tool (nroff) maybe no good. What html? Perhaps this could help??
Anyone for a Mutiny ?
Richard_115
Frequent Advisor

Re: bold and underline words created in kornshell script

My e-mail client has HTML format, but how would that work?
Graham Cameron_1
Honored Contributor

Re: bold and underline words created in kornshell script

Richard.
Or is it Debbie ?

Your korn shell script would have to be modified to generate html tags.
The hard way is do do this longhand, like
This text will appear in bold, This will be underlined, etc.

There's doubtless a much easier way in Perl ...

Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Elmar P. Kolkman
Honored Contributor

Re: bold and underline words created in kornshell script

You would have to rebuild the script to output HTML instead of plain text. Or to let it generate the text in another markup-language. nroff/troff/groff might be another solution (used for manual pages, for example).

Or, if it is only used for printing, let the script generate for each character to underline the sequence:
And for bold:

This is interpreted by most printers or printer-scripts to generate underline and bold... It is the way old matrix printers worked and supported by current printers for backwards compatibility. Even some terminal emulators support it.
Every problem has at least one solution. Only some solutions are harder to find.
Mark Grant
Honored Contributor

Re: bold and underline words created in kornshell script

Failing that, get a list of escape sequences for particular special effects from your printer manual or it's web site and insert them into the text file around the words you want to affect. These escape sequences will be printer specific.

I didn't know about Elmars' solution above and it would have saved me many a headache over the years!

Never preceed any demonstration with anything more predictive than "watch this"
Procnus
Frequent Advisor

Re: bold and underline words created in kornshell script

I'm not sure if this will help you, but here is a fragment from a shell script that centres and bolds the title of each page:

# print_file prints out the file egenrated by each sysadm function
# Arguments : <br />function print_file {<br /> pf=$1<br /> shift<br /> arglen=$(echo $* | wc -c)<br /> let arglen=arglen/2<br /> let offset=40-arglen<br /> echo '^[E^[(s3B^[&a'$offset'C' $* '^[(s0B^[&k2G' | cat - $pf | lp -d<br />islaser<br /> # PCL codes are as follows:<br /> # ^[E - PCL reset<br /> # ^[(s3B - Turn on bolding<br /> # ^[&a'$offset'C - Horizontal offset in characters<br /> # ^[(s0B - Turn off bolding<br /> # ^[&k2G - Ensure CR=CR, LF=CR+LF and FF=CR+FF<br />} <br /><br />The ^[ above is Escape. The code to enable underline is ^[&d0D to disable it the code is ^[&d@<br /><br />Cheers<br />Steven<br />
Bill Hassell
Honored Contributor

Re: bold and underline words created in kornshell script

This gets really complicated. Unlike PCs, HP-UX has no printer meta-language and doesn't know anything about bold or underline. That's what a word processor does--with the help of the meta-language. Like HTML, a meta-language is a target-neutral way of defining enhancements. Then the printing process interprets these codes and translates them into downloaded fonts and enhancement triggers.

So the answer starts with: how much trouble do you want to go to for this task? You'll need to know what language your printer supports (ie, PCL, Epson, Postscript) and what the escape codes might be to turn on (and also turn off) the enhancements. You then either:

- insert the printer-specific codes before and after the to-be-bold text using vi or sed,

- insert meta-characters such as and before and after the bold words, then write a script to change the codes into printer enhancement codes and pipe to the printer.

Or you can just use a PC to do the job in a simple word processor like Wordpad.


Bill Hassell, sysadmin