Newsgroups: comp.unix.sco.misc Subject: Re: Why can't I echo control codes with SED References: <HhhO5.102$B55.19058755@news1.pvt.primus.ca> From: spcecdt@deeptht.armory.com. (John DuBois) Message-ID: <_2oO5.204$34.9914@e420r-sjo3.usenetserver.com> X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Date: Thu, 09 Nov 2000 02:34:34 GMT In article <HhhO5.102$B55.19058755@news1.pvt.primus.ca>, Dean Northam <alltemp@globalserve.net> wrote: >I tried text2post for a form overlay but dropping in the eps in the right >point in the postscript language is frustrating at best and I hit a brick >wall with it. I've now switched gears to enscript and have better luck so >far with it. Only problem is when I try to insert a "\000" into my print out >I get "\200", so I thought I would dump it thru sed and do a search and >replace. But it seems to me that sed does not like control codes very much. >So far I have this but the control codes are NOT being captured: > >sed 's/\\200epsf/'`echo "\000"`'epsf/' $file | > /usr/local/bin/enscript -B -e -fCourier12@11.6 -p- > >all that ends up in the files is "epsf[n]{/tmp/test.eps}" There are a couple of things wrong with this. First, under no circumstance can a null character be passed in the argument vector to an exec'd program, which is what you're trying to do when you give these arguments to an executable on the command line. The strings in the argument vector are terminated by nulls, so nulls can't be embedded in them; see exec(S).
You could try to work around this by including them in a script file, but it
still wouldn't work, because sed can't deal with nulls in its program. It,
too, uses nulls to terminate strings.
awk, as well, can't introduce nulls into its output, but gawk can.
Interestingly, tr discards nulls from its input, but can introduce them into
its output. If you don't actually need the 'epsf' context, and your input
will never include null characters, use this:
tr '\200' '\0' < $file | enscript ...
Otherwise, get gawk and use something like:
gawk '{gsub("\200epsf","\0epsf");print}' $file | enscript ...
John
--
John DuBois spcecdt@armory.com. KC6QKZ/AE http://www.armory.com./~spcecdt/
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar