Why can't I echo control codes with SED

Why can't I echo control codes with SED

Post by Dean Northa » Thu, 09 Nov 2000 04:00:00



Hello ALL:

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 |

all that ends up in the files is "epsf[n]{/tmp/test.eps}"

Help, please help, while I still have some hair left,

Thanks Dean

 
 
 

Why can't I echo control codes with SED

Post by Darryl Krasma » Thu, 09 Nov 2000 04:00:00



> Hello ALL:

> 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 |

> all that ends up in the files is "epsf[n]{/tmp/test.eps}"

> Help, please help, while I still have some hair left,

> Thanks Dean

How are you trying to put $00$ in the print stream? If a $00$ is too
difficult why not specify a different character in your '-e' option?
--
Darryl
Ideal Computer Group Inc.

 
 
 

Why can't I echo control codes with SED

Post by John DuBo » Fri, 10 Nov 2000 11:34:34




>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 |

>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
--

 
 
 

1. progname=`$echo "$0" | sed 's%^.*/%%'` bears no result!!!

This should be doing what 'basename' does for a simple invocation.  I
tried sending '/usr/bob' and 'bob' to sed and in both cases got 'bob'
back.  So using 'basename' (and 'dirname' if needed for the directory)
may work.

But, given that "$0" should always be the name of the script, the
variable progname should never be null...so something is rather odd
here.  What is your environment (OS, shell, method of invoking the
script, etc.)?

In progress...

Bob McGowan

2. cant get thru squid

3. TOO SLOW: `echo ${LINE} | sed -n 's/^.* proto //p' | cut -f1 -d" "`

4. GCC problem ?

5. Why doesn't echo "text" 'command' "more text" work?

6. No one logged on under X?

7. (sed 1q ; sed 2q) : no output from 2nd 'sed'

8. ptrace on stopped processes (2.4)

9. Why doesn't echo "text" 'command' "more text" work?

10. Why no output for 'which echo'?

11. echo '\a' does not work, Why?

12. Why doesn't sed 's/$/^M/' work as expected?

13. tcsh dosen't echo ^[ as a control character