Operating System - HP-UX
1753511 Members
5314 Online
108795 Solutions
New Discussion юеВ

Re: Add PCL Commands to a file

 
SOLVED
Go to solution
Andy Haigh_1
Frequent Advisor

Add PCL Commands to a file

I am currently taking a print file and adding PCL commands to the start and end of the file by creating a start and end file with the PCL commands in and cat them together with the print file. This works but this adds a CR LF into the file which prints the first page one line down. I have tried using sed to add the PCL string to the print file but get a string can't be parsed error. Probably due to the escape characters in the PCL string.

Here is what I have in my script, I am trying to add PCL to the front of a file and then add PCL to the end of the file.

sed '1i\/E&l1o0e66f66p7h8D&l26A&a0l132M(s13H&k2G\' $1 > $1.init

sed '$a\\&l0HE' $1.init > $1.exit


Can anyone assist by letting be know what I am doing wrong.

Thanks

Andy
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: Add PCL Commands to a file

> [...] This works but this adds a CR LF into

Well, perhaps LF.

> the file which prints the first page one
> line down. [...]

What's in your files? ("man od".)

The following is with Bash on a Solaris
system, and the "echo" details may be
different elsewhere, but ...

ra# echo -n 'abc>' > file_start.txt
ra# echo -n ' file_end.txt
ra# cat file_text.txt
Line 1.
Line 2.
Line 3.
ra# cat file_start.txt file_text.txt file_end.txt
abc>Line 1.
Line 2.
Line 3.

No new newline characters there. It not be
natural (or middle-class), but it is possible
(even with a shell script) to create a file
containing text without a newline character.

"man sed" (and/or its friends) might reveal
some exotic octal coding scheme ("\033"?)
which would let you put an ESC into a
command, but I'd probably stick with the
loose files. Of course, as usual, many
things are possible.
Steven Schweda
Honored Contributor

Re: Add PCL Commands to a file

> [...] It not be [...]

Make that: [...] It might not be [...]

(Why do I always see these right _after_
hitting "Submit"?)
Andy Haigh_1
Frequent Advisor

Re: Add PCL Commands to a file

Hi Steven,
This is basically what I am doing know. Here is the script and output on HP/UX

echo "E&l1o0e66f66p7h8D&l26A&a0l132M(s13H&k2G" > +
echo "&l0HE" > print.exit
cat print.init print.file print.exit

Output:

E&l1o0e66f66p7h8D&l26A&a0l132M(s13H&k2G
LINE 1
LINE 2
LINE 3
LINE 4
LINE 5
&l0HE

As you can see the PCL and LINE 1 are on different lines.

Thanks

Andy
Steven Schweda
Honored Contributor
Solution

Re: Add PCL Commands to a file

> This is basically what I am doing [now].
> [...]

Yes, and if "basically" were close enough,
then you'd be home already.

> As you can see the PCL and LINE 1 are on
> different lines.

Yes, and, as I hope that _you_ can see, in my
demonstration, "abc>" and "Line 1." came out
on the same line. It's the miracle of "-n"
(or equivalent).
Andy Haigh_1
Frequent Advisor

Re: Add PCL Commands to a file

Would have helped if I noticed the "-n", sorry about that.

The equivalent is \c on the HP/UX box.

Problem solved.

Thanks

Andy