X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: Date: Wed, 23 Jul 2008 16:20:15 -0400 From: "Mark J. Reed" To: cygwin AT cygwin DOT com Subject: Re: lpr works? FAQ in error? In-Reply-To: <103f84ldjk247ihimh4enrpp7tmoc0sgos@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <380-2200855974950906 AT cantv DOT net> <9a498418e4cd1ia8ll54i7eqiehdjmq0m5 AT 4ax DOT com> <31DDB7BE4BF41D4888D41709C476B6570929B1FA AT NIHCESMLBX5 DOT nih DOT gov> <103f84ldjk247ihimh4enrpp7tmoc0sgos AT 4ax DOT com> X-Google-Sender-Auth: 02e4646c1eb31a49 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 -- 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/