amrox
asked on
stdin pipe to expect script
I want to feed a string to an expect script and have it stored in a variable and used as a password.
Needs to be invoked as:
echo "my_password" | ./myscript.exp
Anyone know how to do this?
Please see script example below:
Needs to be invoked as:
echo "my_password" | ./myscript.exp
Anyone know how to do this?
Please see script example below:
#!/usr/bin/expect -f
#### *** insert some command here to set $PASSWD to stdin ***
spawn ssh test@localhost
expect "*?password:*" { send "$PASSWD\n" }
expect "$ "
send "exit\n"
interact
You'd better run your script as ./myscript.exp "my password". Then you can create $PASSWD very simple: set PASSWD [lindex $argv 0]
ASKER
yes, I know how to use arguments, but this is not what I want.
Is it possible to do what I've asked?
Is it possible to do what I've asked?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.