Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Waugh
On Wed, 2011-05-25 at 10:47 +0100, Ralph Corderoy wrote:
> It may be that CUPS lets one specify the incoming charset too but I
> didn't see anything obvious.  Locale environment variables perhaps?

It used to be the case that you could specify it like this:

lp -o document-format="text/plain;charset=..." ...

but I think that CUPS requires UTF-8 now, for all IPP requests and for
input text documents.

Tim.
*/



signature.asc
Description: This is a digitally signed message part
--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue

Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Ralph Corderoy
Hi,

> So bash sees an argv[] of
>
> bash
> -c
> tr
> f
> g
>
> and -c takes just the next argument as the command to run, here tr.
> The following arguments are used to set the positional parameters, $1,
> $2, etc., which aren't used in this case.

I'm wrong there.  They're used to set $0, $1, etc.

$ ssh $remote 'bash -c \$1\$2 foo da te'
Wed May 25 13:17:02 BST 2011
$

`foo' becomes $0, as shown by

$ ssh $remote 'bash -c \${@:0} ls -ld / /etc'
drwxr-xr-x  23 root root  4096 2011-04-23 10:09 /
drwxr-xr-x 165 root root 12288 2011-05-25 10:53 /etc
$

Cheers, Ralph.

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Allen

Hi Ralph

On 25/05/11 12:16, Ralph Corderoy wrote:

and -c takes just the next argument as the command to run, here tr.  The
following arguments are used to set the positional parameters, $1, $2,
etc., which aren't used in this case.  tr grumbles as seen above when
run with no arguments.  Since cat isn't given any arguments, nor does it
need any, it avoids the issue.

Removing one of the extra levels of parsing by getting rid of the bash
works.

 $ echo foo | ssh $remote tr f g \| hd
   67 6f 6f 0a   |goo.|
 0004
 $ echo foo | ssh $remote 'tr f g | hd'
   67 6f 6f 0a   |goo.|
 0004
 $

So in a DOS batch file,

 type JUNK.S0 | ssh server "iconv -f IBM850 -t UTF8 | lpr -PLaserjet -o cpi=11.5 
-o lpi=6 -o page-left=54"

should work.

Yes, it does. I'd assumed John was using bash to overcome some ssh 
parsing issue with the pipeline. I recall some limitations when using 
rssh but can't remember the details.


Cheers

Tim

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Ralph Corderoy
Hi Tim,

> > VSpike wrote:
> > > type %1 | ssh server bash -c "cat | iconv -f IBM850 -t UTF8 | lpr 
> > > -PLaserjet"
> >
> > Why the cat?  ;-)
>
> Going through SSH, it's not happy without it:
>
> C:\>type JUNK.S0   | ssh server /bin/bash -c "iconv -f IBM850 -t UTF8
> | lpr -PLaserjet -o cpi=11.5 -o lpi=6 -o page-left=54"
> iconv: illegal input sequence at position 257

We were just talking about this on IRC.  John pointed out that cat was
needed.  He's right, but it's really hiding the symptom of a different
problem.

Take a variant on John's IRC example,

$ echo foo | ssh $remote bash -c 'tr f g | hd'
tr: missing operand
Try `tr --help' for more information.
$

adding a cat fixes it.

$ echo foo | ssh $remote bash -c 'cat | tr f g | hd'
  67 6f 6f 0a   |goo.|
0004
$

tr's complaint gives the clue.  Because of the extra level of
interpretation caused by the ssh/sshd what's being run remotely is

bash -c tr f g | hd

The shell that's handling this remotely arranges for the explicit bash
and the hd to be run, piped together.  So bash sees an argv[] of

bash
-c
tr
f
g

and -c takes just the next argument as the command to run, here tr.  The
following arguments are used to set the positional parameters, $1, $2,
etc., which aren't used in this case.  tr grumbles as seen above when
run with no arguments.  Since cat isn't given any arguments, nor does it
need any, it avoids the issue.

Removing one of the extra levels of parsing by getting rid of the bash
works.

$ echo foo | ssh $remote tr f g \| hd
  67 6f 6f 0a   |goo.|
0004
$ echo foo | ssh $remote 'tr f g | hd'
  67 6f 6f 0a   |goo.|
0004
$

So in a DOS batch file,

type JUNK.S0 | ssh server "iconv -f IBM850 -t UTF8 | lpr -PLaserjet -o 
cpi=11.5 -o lpi=6 -o page-left=54"

should work.

(One might need to explicitly run bash if using a bashism and not
confident the remote shell would always be bash, but then extra quoting
must also be added.)

Cheers, Ralph.

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Allen

Hi Ralph

On 25/05/11 10:47, Ralph Corderoy wrote:

Hi John,

I agree, iconv(1).

VSpike wrote:

type %1 | ssh server bash -c "cat | iconv -f IBM850 -t UTF8 | lpr -PLaserjet"


Why the cat?  ;-)


Going through SSH, it's not happy without it:


C:\>type JUNK.S0   | ssh server /bin/bash -c "iconv -f IBM850 -t UTF8 | 
lpr -PLaserjet -o cpi=11.5 -o lpi=6 -o page-left=54"

iconv: illegal input sequence at position 257

Cheers

Tim


--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Ralph Corderoy
Hi John,

I agree, iconv(1).

VSpike wrote:
> type %1 | ssh server bash -c "cat | iconv -f IBM850 -t UTF8 | lpr -PLaserjet"

Why the cat?  ;-)

$ dc -e 16i666F6F9C6261720AP | iconv -f ibm850 -t utf8
foo£bar
$ 

It may be that CUPS lets one specify the incoming charset too but I
didn't see anything obvious.  Locale environment variables perhaps?
Using iconv would mean it works with lesser lpr's anyway, or if
something other than printing is required.

Cheers, Ralph.

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue

Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Allen

Hi John

On 25/05/11 10:23, John Carlyle-Clarke wrote:

On 25/05/11 09:35, Tim Allen wrote:

Hi

I'm using lpr to print out files generated by an ancient DOS program. I
have a batch file that uses Cygwin OpenSSH to send to a printer:

type %1 | ssh server lpr -PLaserjet

Now the DOS program uses extended ASCII 09Ch for '£' symbols, now
printing as little rectangles.

I believe SSH is irrelevant to all this, as it should be 8-bit clean. I
can confirm this by viewing the file in a Gnome terminal (Debian
Squeeze). Again I see little rectangles under UTF8 but selecting the
IBM850 character set displays the file correctly.

So I think the question is, how can I tell CUPS lpr to use code page
850? I can't find any relevant -o options in the lpr docs. Maybe I need
to hack /usr/lib/cups/filter/textonly (I see it has Tim W's name on
it!!)?



Hi Tim-

What about:-

type %1 | ssh server bash -c "cat | iconv -f IBM850 -t UTF8 | lpr
-PLaserjet"



Brilliant! Exactly what I needed - I didn't know about iconv - very handy.

Thanks

Tim


Best regards,

John

--
Next meeting: Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
How to Report Bugs Effectively: http://goo.gl/4Xue




--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread John Carlyle-Clarke

On 25/05/11 09:35, Tim Allen wrote:

Hi

I'm using lpr to print out files generated by an ancient DOS program. I
have a batch file that uses Cygwin OpenSSH to send to a printer:

type %1 | ssh server lpr -PLaserjet

Now the DOS program uses extended ASCII 09Ch for '£' symbols, now
printing as little rectangles.

I believe SSH is irrelevant to all this, as it should be 8-bit clean. I
can confirm this by viewing the file in a Gnome terminal (Debian
Squeeze). Again I see little rectangles under UTF8 but selecting the
IBM850 character set displays the file correctly.

So I think the question is, how can I tell CUPS lpr to use code page
850? I can't find any relevant -o options in the lpr docs. Maybe I need
to hack /usr/lib/cups/filter/textonly (I see it has Tim W's name on it!!)?



Hi Tim-

What about:-

type %1 | ssh server bash -c "cat | iconv -f IBM850 -t UTF8 | lpr 
-PLaserjet"


Best regards,

John

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Allen

On 25/05/11 09:35, Tim Allen wrote:

Hi

I'm using lpr to print out files generated by an ancient DOS program. I
have a batch file that uses Cygwin OpenSSH to send to a printer:

type %1 | ssh server lpr -PLaserjet

Now the DOS program uses extended ASCII 09Ch for '£' symbols, now
printing as little rectangles.

I believe SSH is irrelevant to all this, as it should be 8-bit clean. I
can confirm this by viewing the file in a Gnome terminal (Debian
Squeeze). Again I see little rectangles under UTF8 but selecting the
IBM850 character set displays the file correctly.

So I think the question is, how can I tell CUPS lpr to use code page
850? I can't find any relevant -o options in the lpr docs. Maybe I need
to hack /usr/lib/cups/filter/textonly (I see it has Tim W's name on it!!)?


Oops - textonly is for text only printers so that's a red herring!

Tim


--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


[Dorset] CUPS lpr and code pages

2011-05-25 Thread Tim Allen

Hi

I'm using lpr to print out files generated by an ancient DOS program. I 
have a batch file that uses Cygwin OpenSSH to send to a printer:


type %1 | ssh server lpr -PLaserjet

Now the DOS program uses extended ASCII 09Ch for '£' symbols, now 
printing as little rectangles.


I believe SSH is irrelevant to all this, as it should be 8-bit clean. I 
can confirm this by viewing the file in a Gnome terminal (Debian 
Squeeze). Again I see little rectangles under UTF8 but selecting the 
IBM850 character set displays the file correctly.


So I think the question is, how can I tell CUPS lpr to use code page 
850? I can't find any relevant -o options in the lpr docs. Maybe I need 
to hack /usr/lib/cups/filter/textonly (I see it has Tim W's name on it!!)?


Cheers

Tim

--
Next meeting:  Bournemouth, Tuesday 2011-06-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue