RE: lpr works? FAQ in error?

2008-07-24 Thread Buchbinder, Barry (NIH/NIAID) [E]
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.


Re: lpr works? FAQ in error?

2008-07-23 Thread Wilfried
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/



Re: lpr works? FAQ in error?

2008-07-23 Thread Mark J. Reed
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 [EMAIL PROTECTED]

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



Re: lpr works? FAQ in error?

2008-07-23 Thread Mark J. Reed
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 [EMAIL PROTECTED]

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



RE: Re: lpr works? FAQ in error?

2008-07-22 Thread Buchbinder, Barry (NIH/NIAID) [E]
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/



Re: lpr works? FAQ in error?

2008-07-21 Thread Wilfried
jrsyangl [EMAIL PROTECTED] 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/



Re: lpr works? FAQ in error?

2008-07-21 Thread Wilfried
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/



Re: lpr works? FAQ in error?

2008-07-18 Thread Rodrigo Medina
Lou Umscheid 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. Is there a simple way to do this?

The problem with lpr is that it sends the file as it is to the printer, and
modern printers require some kind of translation of the file to their own
special language. You can send a text file to the printer using the
windows program NOTEPAD /P
For runnig notepad from a cygwin terminal you can use the command
cygstart. For example
cygstar notepad file.txt
opens file.txt in notepad.
cygstart notepad /P file.txt
sends file.txt to the printer.
The are 2 additional problems. Notepad prints Windows text files, with
the CRLF line endings. If your file is a unix text file with LF endings you
need
first to pass the file through the unix2dos filter that is part of the
cygutils.
The other problem is that Notepad does not know about cygwin pipes,
but you can make a bash script that passes the pipe input through the
unix2dos filter, writes the result in a temporal file, prints the file with
NOTEPAD /P and deletes the temporal file.

RM


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



Re: lpr works? FAQ in error?

2008-07-17 Thread Lou Umscheid
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/



Re: lpr works? FAQ in error?

2008-07-17 Thread jrsyangl
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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/



lpr works? FAQ in error?

2008-05-08 Thread Lee D. Rothstein

Cygwin FAQ says:

FAQ: Q: How do I print under Cygwin?
FAQ:
FAQ: A: There is no working lp or lpr system as you would find on
FAQ:UNIX.
FAQ:
FAQ:Jason Tishler has written a couple of messages that explain
FAQ:how to use a2ps (for nicely formatted text in PostScript) and
FAQ:ghostscript (to print PostScript files on non-PostScript
FAQ:Windows printers). Start at
FAQ:http://cygwin.com/ml/cygwin/2001-04/msg00657.html. Note that
FAQ:the file command is now available as part of Cygwin setup.
FAQ:
FAQ:Alternatively, on NT, you can use the Windows print command.
FAQ:(It does not seem to be available on Win9x.) Type

I've gotten /usr/bin/lpr to work under Vista. So is the FAQ in error?

My problem is finding a filter for Epson printers. I guess the
best bet is man2html to FireFox, et al.

Lee Rothstein


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