From: news_reader@mew.corp.sgi.com (Pablo Sanchez) Newsgroups: comp.databases.sybase,comp.answers,news.answers Subject: Sybase FAQ: 5/16 - section 4 Supersedes: <FAQ.section_4_868292146@sgi.com> Followup-To: comp.databases.sybase Date: 1 Aug 1997 06:01:11 GMT Organization: Silicon Graphics, Inc. Nederland, CO. USA Message-ID: <FAQ.section_4_870415202@sgi.com> References: <FAQ.section_3_870415202@sgi.com> Reply-To: pablo@sgi.com Summary: Info about SQL Server, bcp, isql and other goodies Posting-Frequency: monthly Archive-name: databases/sybase-faq/part5 URL: http://reality.sgi.com/pablo/Sybase_FAQ Q4.1: HIDING YOUR PASSWORD TO _ISQL_ _________________________________________________________________ Here are a menagerie (I've always wanted to use that word) of different methods to hide your password. Pick and choose whichever fits your environment best: Single SQL Server on host Script #1 Assuming that you are using bourne shell _sh(1)_ as your scripting language you can put the password in a file and substitute the file where the password is needed. #!/bin/sh # invoke say ISQL or something.... ( cat $HOME/dba/_password_file_ cat Script #2 #!/bin/sh umask 077 cat Script #3 #!/bin/sh umask 077 cat Script #3 #!/bin/sh umask 077 isql -Umyuserid -Smyserver Script #4 #!/bin/sh umask 077 isql -Umyuserid -Smyserver Script #5 #!/bin/sh echo 'mypassword use mydb go sp_who go' | isql -Umyuserid -Smyserver Script #6 #!/bin/sh echo "`myScriptForGeneratingPasswords myServer` use mydb go sp_who go" | isql -Umyuserid -Smyserver Script #7 Apparently solaris precludes hiding passwords. While _isql_ tries, solaris is too smart for it and puts them back on the command line. We just came up with a clever option for this: isql -w000000000000000000000000000000000001 -Pmypass ... Apparently solaris' _ps(1)_ is too brain dead to to wrap and will only show the first 40 characters or so of the command so you need to guarantee that the password is after that. I think this is 100%, but we will be fooling around with it a bit more. Multiple SQL Servers on host Again, assuming that you are using bourne shell as your scripting language, you can do the following: 1. Create a _global file_. This file will contain passwords, generic functions, master device for the respective DSQUERY. 2. In the actual scripts, source in the _global file_. _Global File_ SYBASE=/usr/sybase my_password() { case $1 in SERVER_1) PASSWD="this";; SERVER_2) PASSWD="is";; SERVER_3) PASSWD="bogus;; *) return 1;; esac return 0 } Generic Script #!/bin/sh -a # # Use "-a" for auto-export of variables # # "dot" the file - equivalent to csh() "source" command . $HOME/dba/_global_file_ DSQUERY=$1 # Determine the password: sets PASSWD my_password $DSQUERY if [ $? -ne 0 ] ; then # error! echo "" exit 1 fi # invoke say ISQL or something.... echo "$PASSWD dbcc ... go" | $SYBASE/bin/isql -U sa -S $DSQUERY -w1000 _______________________________________________________________ Q4.2: HOW TO REMOVE _ROW AFFECTED_ AND DASHES _________________________________________________________________ If you pipe the output of _isql_ then you can use _sed(1)_ to remove this extraneous output: echo "$PASSWD sp_who go" | isql -U sa -S MY_SERVER | sed -e '/affected/d' -e '/---/d' If you simply wish to eliminate the _row affected_ line use the _set nocount on_ switch. _________________________________________________________________ Q4.3: HOW DO I PIPE THE OUTPUT OF ONE _ISQL_ TO ANOTHER? _________________________________________________________________ The following example queries _sysdatabases_ and takes each database name and creates a string of the sort _sp_helpdb dbname_ and sends the results to another _isql_. This is accomplished using bourne shell _sh(1)_ and _sed(1)_ to strip unwanted output (see Q4.2): #!/bin/sh PASSWD=yuk DSQUERY=GNARLY_HAIRBALL echo "$PASSWD print \"$PASSWD\" go select 'sp_helpdb ' + name + char(10) + 'go' from sysdatabases go" | isql -U sa -S $DSQUERY -w 1000 | \ sed -e '/affected/d' -e '/---/d' -e '/Password:/d' | \ isql -U sa -S $DSQUERY -w 1000 To help you understand this you may wish to comment any series of pipes and see what output is being generated. _________________________________________________________________ -- Pablo Sanchez | Ph # (415) 933.3812 Fax # (415) 933.2821 pablo@sgi.com | Pg # (800) 930.5635 -or- pablo_p@corp.sgi.com =============================================================================== I am accountable for my actions. http://reality.sgi.com/pablo [ /Sybase_FAQ ]
[
By Archive-name
| By Author
| By Category
| By Newsgroup
]
[
Home |
Latest Updates |
Archive Stats |
Search |
Usenet References |
Help
]
Send corrections/additions to the FAQ Maintainer:
Last Update August 12 1997 @ 02:37 AM faq-admin@faqs.org