Re: Proposed patch to datacopy to allow passwords to be read from stdin
"James K. Lowden" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 16 Aug 2012 11:36:21 -0400 "[email protected]" <[email protected]> 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