delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/05/21/15:43:01

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "John Morrison" <john DOT r DOT morrison AT ntlworld DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Setting default printer in startup scripts
Date: Wed, 21 May 2003 20:40:50 +0100
Message-ID: <NCEBJJFMCAOKNNABBFIMAENGDMAA.john.r.morrison@ntlworld.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <Pine.GSO.4.44.0305211006120.26639-100000@slinky.cs.nyu.edu>
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Importance: Normal

> From: Igor Pechtchanski
> On Wed, 21 May 2003, Corinna Vinschen wrote:
>
> > On Wed, May 21, 2003 at 10:00:01AM +0100, David Kilroy wrote:
> > > # Define default printer
> > > if [ $OS = Windows_NT ]; then
> > >   PRINTER=`regtool get '\user\Software\Microsoft\Windows
> > > NT\CurrentVersion\Windows\Device'|sed 's?\([^,]*\),.*?\1?g'`
> > > else
> > >   PRINTER=`regtool get
> > > '\config\System\CurrentControlSet\Control\Print\Printers\Default'`
> > > fi
> > >
> > > Note: I haven't tested the above much. It works on my NT box
> with a network
> > > printer, and I've verified an ME box has the appropriate
> registry entry.
> >
> > The backslashes are somewhat dangerous since they get evaluated as
> > special characters.  Why not use forward slashes instead?  regtool
> > supports them as registry key separator.
> >
> > Corinna
>
> Corinna,
>
> The backslashes are dangerous unless quoted.  They seem to be properly
> quoted in the above.  So, either way is fine.  The *result* of regtool,
> however, may contain all kinds of characters (including spaces), and it's
> *not* quoted.  I'm also a bit wary of using OS-specific variables, such
> as, well, "$OS".  So, how about the following:
>
> # Define default printer
> OUR_OS="`uname -s`"
> case "$OUR_OS" in
>   CYGWIN_NT-*)
>       PRINTER="`regtool get '\user\Software\Microsoft\Windows
> NT\CurrentVersion\Windows\Device'|sed 's/,.*$//'`"
>       ;;
>   CYGWIN_9?-*)
>       PRINTER="`regtool get
> '\config\System\CurrentControlSet\Control\Print\Printers\Default'`"
>       ;;
> esac
>
> I can also confirm that the first key exists (and works) on Win2k, and the
> second key exists (and works) on Win98.
>
> FWIW, I'd like to see this in the base-files package.  John?

*GRIN* Flag'd for followup, unfortunaely, I won't be able to do
anything until next Friday.  I'm away the weekend and most of
the following week, I'll catch up on the thread then.

J.

PS, I'll be getting back to the /etc/.profile around the same
time :/


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019