Ok, I have a script I use for passing a username/password to log into Oracle. The same method should be able to be used for what you are attempting. I have not tried it, give me some time, and I will try it for you.
First script you would call is get_pw. get_pw calls variable pwfile. pwfile gives the path to a file named do_not_delete which contains the username and password you want to pass in the script. To ensure security, the file do_not_delete is compressed, and renamed. Both files are also hidden.
Example 1: "get_pw"
#!/bin/sh
pwfile=${OPATH}/.do_not_delete
if [ -f $pwfile ]
then
host=$1
sid=$2
account=$3
passwd=`zcat <$pwfile| awk '$1=="'$host'" && $2=="'$sid'" && $3=="'$account'"{print $4}'`
if [ -z "$passwd" ]
then
echo "****Error*** No password found for specified parameters"
exit 1
else
echo $passwd
fi
else
echo "***Error*** You are not set up to use this utility"
exit 1
fi
Note in get_pw: The OPATH is not defined in this script. I am using this as an added level of safety. Since under normal circumstances, this script is called from another script which has set the OPATH variable. If someone with
priviledges runs this script directly, the absense of this variable will cause it to fail.
Example 2: do_not_delete
node sid id pw
hostname ORA1 username password
FYI, the following comes from the getpass(3c) man page:
[tt]The getpass() function opens the process' controlling terminal, writes to that device the null-terminated string prompt, disables echoing, reads a string of characters up to the next newline character or EOF, restores the terminal state and closes the terminal.[/tt]
This is the function that is normally used to read passwords. As you can see, it reads the password directly from the terminal and not from stdin.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.