Skip to Content.
Sympa Menu

freetds - Re: [freetds] Proposed patch to datacopy to allow passwords to be read from stdin

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Proposed patch to datacopy to allow passwords to be read from stdin
  • Date: Sat, 18 Aug 2012 15:36:38 -0400

On Thu, 16 Aug 2012 11:36:21 -0400
"PublicMailbox AT benslade.com" <PublicMailbox AT benslade.com> wrote:

> Upon finding a dash for the password, datacopy would prompt for the
> password and read it in.
>
> Using a dash for a parameter to specify "read from stdin" is a
> typical style for many Unix/Linux utilities.

A dash is commonly recognized as an alias for standard input, but it's
rarely used for passwords. And nowadays most systems
support /dev/stdin, freeing the utility from assigning special meaning
to '-'.

Why not interpolate instead? To read a password on stdin, something
has to produce it on stdout. Just insert it at the right place using
`` or $().

Before we fully supported Kerberos, I kept passwords in ${HOME}/.netrc,
a file traditionally used by many ftp utilities and some others,
including fetchmail and wget. For a description of the format, see e.g.
http://man.cx/netrc (4).

I had a script such as

#! /bin/sh
awk "\$2 == \"$1\" {print \$6}" ~/.netrc

called "getpass". Now the command:

datacopy -S$S/$U/$(getpass $S)/$D/$T ...

does the job.

> Using kerberos might be better, but that's a much harder change.

Not that much harder, and worthwhile if your environment supports it.
Look at what the other db-lib utilities do.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page