public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE:lpr works? FAQ in error?
@ 2008-05-09  8:44 Rodrigo Medina
  2008-07-17 22:19 ` lpr " Lou Umscheid
  0 siblings, 1 reply; 10+ messages in thread
From: Rodrigo Medina @ 2008-05-09  8:44 UTC (permalink / raw)
  To: cygwin

Lee D. Rothstein on Fri, 09 May 2008 01:26:09 -0400 wrote:
>I've gotten /usr/bin/lpr to work under Vista. So is the FAQ in error?

It is in error. There is a working lpr which is part or cygutils. See man
pages.

> My problem is finding a filter for Epson printers.

For modern Epson printers you may use the IJS drive of ghostscript
You have to;
1- Install ghostscript 
2- Install gutenprint and foomatic
there few problems. See:
http://sourceware.org/ml/cygwin/2006-05/msg00566.html
and
http://sourceware.org/ml/cygwin/2006-05/msg00575.html

An easier way is to used the Windows drivers. You need a Windows program
that could print.
You may use  "NOTEPAD /P" for text files and "Foxit Reader /p" for PDF files
You can use ghostscript for transforming ps files into PDF files
Foxit Reader is a faster than Acrobat Reader and has the convenient switch
"/p" for printing.

For example I use the following script (lprps) for printing postscript
files:

#!/bin/bash
## Para mandar un archivo PostScript a la impresora
## convirtiendolo en PDF y escribiendolo con Foxit
FRDIR="/cygdrive/c/Program Files/Foxit Software/Foxit Reader/Foxit
Reader.exe"
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.4
 -sOutputFile=/tmp/~lprps.pdf $1 ;
FDIR=`cygpath -wa /tmp/~lprps.pdf`
cygstart "$FRDIR" /p $FDIR
exit 0

The command
$ lprps FILE.ps
prints FILE.ps

I hope that this can be useful 
R.M.





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-05-09  8:44 RE:lpr works? FAQ in error? Rodrigo Medina
@ 2008-07-17 22:19 ` Lou Umscheid
  2008-07-18  2:29   ` jrsyangl
  0 siblings, 1 reply; 10+ messages in thread
From: Lou Umscheid @ 2008-07-17 22:19 UTC (permalink / raw)
  To: cygwin

Rodrigo Medina <rodmedina <at> cantv.net> writes:

> It is in error. There is a working lpr which is part or cygutils. See man
> pages.
> 
> An easier way is to used the Windows drivers. You need a Windows program
> that could print.
> You may use  "NOTEPAD /P" for text files and "Foxit Reader /p" for PDF files
> 
> I hope that this can be useful 
> R.M.

I can't get lpr to work printing a text file with XP SP2. The file flashes on 
the que as spooling, but never prints to my Canon MP530. lpr -D looks ok to me. 
Can you advise me how to use "NOTEPAD /P"? I am new at Cygwin, so any help 
would be appreciated.
Lou





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-17 22:19 ` lpr " Lou Umscheid
@ 2008-07-18  2:29   ` jrsyangl
  2008-07-21 13:52     ` Wilfried
  0 siblings, 1 reply; 10+ messages in thread
From: jrsyangl @ 2008-07-18  2:29 UTC (permalink / raw)
  To: cygwin

As a follow-up and clarification to my previous post, what I would like 
to be able to do is to pipe output to a printer, e.g.
 ls -l | lpr
This doesn't work for me as I explained previously. Using notepad /P 
instead of lpr doesn't work either. Is there a simple way to do this?
Lou
"Lou Umscheid" <jrsy.angl@verizon.net> wrote in message 
news:loom.20080717T220746-843@post.gmane.org...
> Rodrigo Medina <rodmedina <at> cantv.net> writes:
>
>> It is in error. There is a working lpr which is part or cygutils. See 
>> man
>> pages.
>>
>> An easier way is to used the Windows drivers. You need a Windows 
>> program
>> that could print.
>> You may use  "NOTEPAD /P" for text files and "Foxit Reader /p" for 
>> PDF files
>>
>> I hope that this can be useful
>> R.M.
>




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-18  2:29   ` jrsyangl
@ 2008-07-21 13:52     ` Wilfried
  2008-07-21 14:12       ` Wilfried
  0 siblings, 1 reply; 10+ messages in thread
From: Wilfried @ 2008-07-21 13:52 UTC (permalink / raw)
  To: cygwin

"jrsyangl" <jrsy.angl@verizon.net> wrote:

> As a follow-up and clarification to my previous post, what I would like 
> to be able to do is to pipe output to a printer, e.g.
>  ls -l | lpr
> This doesn't work for me as I explained previously. Using notepad /P 
> instead of lpr doesn't work either.

It surely won't. You cannot feed text into notepad via a pipe.
To print via notepad, you need to write the output of "ls -l" to a file
then print this file via notepad.
Next problem: I have set up cygwin to use unix style line endings as
default. Now if I 
ls -l > tmp_file
and open tmpfile in notepad, notepad doesn't recognize the line endings,
at least not on screen. It nevertheless prints out correctly on my
printer, maybe because the printer itself interprets the line endings
correctly. But it may be better to use another editor instead,
perhaps pfe or pspad.
I ended up using a script -- you may need to modify it for your needs.
Assume you save this script as "abc", then you can call
abc ls -l 
and the script will execute the command "ls -l" and print its output via
notepad.
--------------snip-------------
#!/bin/sh 
$1 $2 $3 $4 $5 > tmp_file
/cygdrive/c/windows/notepad.exe /p tmp_file
rm tmp_file
--------------snip-------------

--
Wilfried Hennings


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-21 13:52     ` Wilfried
@ 2008-07-21 14:12       ` Wilfried
  2008-07-22 21:33         ` Buchbinder, Barry (NIH/NIAID) [E]
  0 siblings, 1 reply; 10+ messages in thread
From: Wilfried @ 2008-07-21 14:12 UTC (permalink / raw)
  To: cygwin

Ehh, I just saw that Rodrigo Medina addressed all these problems.

So the script would probably look like this:

--------------snip-------------
#!/bin/sh 
$1 $2 $3 $4 $5 | unix2dos > tmp_file
cygstart notepad.exe /p tmp_file
rm tmp_file
--------------snip-------------

--
Wilfried Hennings


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE:  Re: lpr works? FAQ in error?
  2008-07-21 14:12       ` Wilfried
@ 2008-07-22 21:33         ` Buchbinder, Barry (NIH/NIAID) [E]
  2008-07-23 20:01           ` Wilfried
  0 siblings, 1 reply; 10+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) [E] @ 2008-07-22 21:33 UTC (permalink / raw)
  To: cygwin, Wilfried

Wilfried wrote on Monday, July 21, 2008 10:11 AM:

> Ehh, I just saw that Rodrigo Medina addressed all these problems.
> 
> So the script would probably look like this:
> 
> --------------snip-------------
> #!/bin/sh
> $1 $2 $3 $4 $5 | unix2dos > tmp_file
> cygstart notepad.exe /p tmp_file
> rm tmp_file
> --------------snip-------------

It looks to me that the command
	$1 $2 $3 $4 $5
has two or three problems:
  (1) Arguments are not quoted.
  (2) One might have more than a command and 4 arguments.
  (3) It is also possible that one may have surprises if /bin/sh is set up so when non-interactive it handles aliases and shell functions differently than expected.
So I would just pipe into the shell script.

The second place is that there is theoretically a race between cygstart and rm.  What happens if rm deleted tmp_file before notepad reads it?  I can think of two ways to handle it.  Adding
	sleep 1
to delay rm by a second will probably usually be enough of a delay.  Substituting
	"$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p tmp_file
for
	cygstart notepad.exe /p tmp_file
to use Windows' start command will wait until notepad is closed.  (This may be longer than you want to wait.)

But I haven't tried this, so it may not work.

--------------snip--------------
#!/bin/sh
unix2dos > tmp_file
cygstart notepad.exe /p tmp_file
sleep 1
rm tmp_file
--------------snip--------------

- Barry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-22 21:33         ` Buchbinder, Barry (NIH/NIAID) [E]
@ 2008-07-23 20:01           ` Wilfried
  2008-07-23 20:20             ` Mark J. Reed
  0 siblings, 1 reply; 10+ messages in thread
From: Wilfried @ 2008-07-23 20:01 UTC (permalink / raw)
  To: cygwin

"Buchbinder, Barry" wrote:

> Wilfried wrote on Monday, July 21, 2008 10:11 AM:
> 
> > Ehh, I just saw that Rodrigo Medina addressed all these problems.
> > 
> > So the script would probably look like this:
> > 
> > --------------snip-------------
> > #!/bin/sh
> > $1 $2 $3 $4 $5 | unix2dos > tmp_file
> > cygstart notepad.exe /p tmp_file
> > rm tmp_file
> > --------------snip-------------
> 
> It looks to me that the command
> 	$1 $2 $3 $4 $5
> has two or three problems:
>   (1) Arguments are not quoted.
>   (2) One might have more than a command and 4 arguments.
>   (3) It is also possible that one may have surprises if /bin/sh is set up so when non-interactive it handles aliases and shell functions differently than expected.
> So I would just pipe into the shell script.
> 
> The second place is that there is theoretically a race between cygstart and rm.  What happens if rm deleted tmp_file before notepad reads it?  I can think of two ways to handle it.  Adding
> 	sleep 1
> to delay rm by a second will probably usually be enough of a delay.  Substituting
> 	"$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p tmp_file
> for
> 	cygstart notepad.exe /p tmp_file
> to use Windows' start command will wait until notepad is closed.  (This may be longer than you want to wait.)
> 
> But I haven't tried this, so it may not work.
> 
> --------------snip--------------
> #!/bin/sh
> unix2dos > tmp_file
> cygstart notepad.exe /p tmp_file
> sleep 1
> rm tmp_file
> --------------snip--------------

Thanks for the discussion.
I had tested my script and it worked for me.
I agree that just 5 parameters may be not enough.
But there is no need to put the sleep command in. 
I had the impression that the script waited until the cygstart command
was finished. But even if not -- Notepad loads the file completely into
memory and then releases the file handle, so one can delete the file
while notepad is still open.
Regards, Wilfried

--
Wilfried Hennings


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-23 20:01           ` Wilfried
@ 2008-07-23 20:20             ` Mark J. Reed
  2008-07-23 20:25               ` Mark J. Reed
  2008-07-24 17:20               ` Buchbinder, Barry (NIH/NIAID) [E]
  0 siblings, 2 replies; 10+ messages in thread
From: Mark J. Reed @ 2008-07-23 20:20 UTC (permalink / raw)
  To: cygwin

On Wed, Jul 23, 2008 at 4:00 PM, Wilfried wrote:
> I had tested my script and it worked for me.

That's usually the case.  Most bugs are things the author didn't think of. :)

> I agree that just 5 parameters may be not enough.

Then why use that number? Why use any number of parameters, instead of
just all of them? e.g.

command="$1"
shift
"$command" "$@"

But still, it's not usually a good idea to pass a command to some
other command and have it run it on your behalf; it vastly restricts
the sort of things you can do in that pipeline.  Better to do as Barry
suggested and just run the command directly and pipe its output into
your 'print this' script.

do a whole | bunch of stuff | myprint.sh

done.

> But there is no need to put the sleep command in.
> I had the impression that the script waited until the cygstart command
> was finished.

Yes, but the cygstart command doesn't wait for the command it starts;
it returns to the shell prompt immediately.  So the script might start
Notepad and then delete the file before Notepad even has a chance to
try to load it.

>  But even if not -- Notepad loads the file completely into
> memory and then releases the file handle, so one can delete the file
> while notepad is still open.

...in which case you still end up with a temp file lying around after
you're done with it...

Something like this (untested):

#!/bin/bash
tmp_file="/tmp/cygprint$$"
if (( $# )); then
   exec < <(cat "$@")
fi
unix2dos >"$tmp_file" || { echo >&2 "$0: error writing $tmp_file"; exit 1; }
"$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p "$tmp_file"
rc=$?
rm "$tmp_file"
exit $rc


-- 
Mark J. Reed <markjreed@gmail.com>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: lpr works? FAQ in error?
  2008-07-23 20:20             ` Mark J. Reed
@ 2008-07-23 20:25               ` Mark J. Reed
  2008-07-24 17:20               ` Buchbinder, Barry (NIH/NIAID) [E]
  1 sibling, 0 replies; 10+ messages in thread
From: Mark J. Reed @ 2008-07-23 20:25 UTC (permalink / raw)
  To: cygwin

On Wed, Jul 23, 2008 at 4:20 PM, I wrote:

> "$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p "$tmp_file"

Whups, that's not going to work. Needs to convert the temp path to Windows form:

"$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p "$(cygpath -w
"$tmp_file")"

-- 
Mark J. Reed <markjreed@gmail.com>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: lpr works? FAQ in error?
  2008-07-23 20:20             ` Mark J. Reed
  2008-07-23 20:25               ` Mark J. Reed
@ 2008-07-24 17:20               ` Buchbinder, Barry (NIH/NIAID) [E]
  1 sibling, 0 replies; 10+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) [E] @ 2008-07-24 17:20 UTC (permalink / raw)
  To: Mark J. Reed, cygwin

Mark J. Reed wrote on Wednesday, July 23, 2008 4:20 PM:
> On Wed, Jul 23, 2008 at 4:00 PM, Wilfried wrote:
>> But there is no need to put the sleep command in.
>> I had the impression that the script waited until the cygstart
>> command was finished.
> 
> Yes, but the cygstart command doesn't wait for the command it starts;
> it returns to the shell prompt immediately.  So the script might
> start Notepad and then delete the file before Notepad even has a
> chance to try to load it.   

Giving cygstart a ` --wait ' option might be useful for some situations.
(Just a thought -- NOT a request!)  But a simple

$ notepad /p "$(cygpath -w "$tmp_file")"

waits for notepad to exit before issuing a new prompt, so one does
not need to do

$ "$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p "$(cygpath -w "$tmp_file")"

or even

$ cygstart --wait notepad /p "$(cygpath -w "$tmp_file")"

(theoretically possible in the future)

- Barry
  -  Disclaimer: Statements made herein are not made on behalf of NIAID.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-07-24 17:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-09  8:44 RE:lpr works? FAQ in error? Rodrigo Medina
2008-07-17 22:19 ` lpr " Lou Umscheid
2008-07-18  2:29   ` jrsyangl
2008-07-21 13:52     ` Wilfried
2008-07-21 14:12       ` Wilfried
2008-07-22 21:33         ` Buchbinder, Barry (NIH/NIAID) [E]
2008-07-23 20:01           ` Wilfried
2008-07-23 20:20             ` Mark J. Reed
2008-07-23 20:25               ` Mark J. Reed
2008-07-24 17:20               ` Buchbinder, Barry (NIH/NIAID) [E]

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).