Read password from a file

Hello Gurus,

This is something i need to implement quite urgently. My requirement is as follows:

  1. We are using Solaris 10, Sun Access Manager appln.
  2. we need to start a domain through script (automated). Syntax of the command goes as below:
 ./asadmin start-domain --user admin domain1 

after this it will prompt for a password

 Enter Password 

I do not have any idea of passing the password in the command line. What i am trying to achieve is after it asks for password, it must be read it from a file where i have already maintained the details.

Please help me out... as I mentioned, it is something i need to test and implement on priority basis.
Thank You.

there is option called

--passwordfile

---------- Post updated at 11:35 AM ---------- Previous update was at 11:34 AM ----------

start-domain.1

1 Like

@itkamaraj: Thank you for the quick and easy solution. I presume the command would be as follows:

 ./asadmin start-domain --user admin --passwordfile passfile domain1 

However I would also like to explore the option of reading the password from the file in the other way. Will it be possible ?

And where (i mean path) this password file is supposed to be placed?

Thank You.

Hi,

The above solution did work in stopping and starting the services when executed through scripts. But we landed into a dicey situation where in all the application services and agents are up but the application page is not openeing (front end). Not really sure if this post is in its right place..but please help.

thank you.

Go with expect programming ... to pass password ..

You can use openssl file encryption and description method .

## Encrypt using openssl with password: sks and delete un-encrypted file
# openssl des3 -e -in a -out aa; rm -fr a
## varify
# cat aa
Salted__�r>��d�K��&�s  ### Here's my script that read the encrypted file 
 # cat test.sh
IFS=$'\n'
for ln in `openssl des3 -d -in aa -out maa -pass pass:sks;cat maa; rm -fr maa`
do
echo $ln
sleep 3
done

--Shirish Shukla

hello dear,

try this
lets say my password is in /home/vipin/password

vi password.sh
pswd =/home/vipin/password

read =$pswd

try this ..

@vipinkumarr89
Your post contains syntax errors and logic errors. Please test before you post.
Also, please look at the date on threads before replying.

Use the 'expect' program. It works like a charm. You can find it on sunfreeware.com.

It can use the following statements:

expect assword
send "the actual passwd"

using "assword" makes it portable because some UNIXs use Password instead of password.

Here is a script segment I wrote to change root password via ssh:

#!/bin/expect -f "$0" ${1+"$@"}
#
# /home/halstead/bin/autopasswd
#
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st argv, passwd as 2nd argv

set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send "$password\r"
expect "assword:"
send "$password\r"
expect eof