Reputation: 651
I want to make script to login into application, its flow is like
Now my problem is I am able to reach till application launching, but not able to provide Username and password through script.
cd cd /ld62_prod
drv
112233 #username
112233 #password
What I am doing wrong.
Upvotes: 1
Views: 25032
Reputation: 4864
Without Security :
You can use this :
echo "User name: $0"
echo "Password: $1"
And you can use the particular values using $0
and $1
.
Refer Shell script for more details .
With Security :
read -s -p "Password: " password
Under Linux (and cygwin) this form works in bash and sh. It may not be standard Unix sh, though.
For more info and options, in bash, type "help read".
$ help read
read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
Read a line from the standard input and split it into fields.
...
-p prompt output the string PROMPT without a trailing newline before
attempting to read
...
-s do not echo input coming from a terminal
Upvotes: 1
Reputation: 32240
You could use expect
, which is a standard tool that can communicate with interactive programs/scripts like yours. Its man page says:
Expect is a program that "talks" to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script.
Upvotes: 0