Results 1 to 2 of 2
Is there a similar thing in expect , as there is 'read'(Read a line from standard input) in bash ? I mean one could easily construct following script in bash: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-03-2010 #1
- Join Date
- Aug 2010
'read' functionality in expect script
I mean one could easily construct following script in bash:
> cat script.sh #!/bin/bash read -p "Username: " uname stty -echo read -p "Password: " passwd; echo stty echo echo "Now I am able to use username(which is $uname in this case) and password($passwd in this case) as variables in the script."
#!/usr/local/bin/expect -f read -p "Username: " uname stty -echo read -p "Password: " passwd; echo stty echo set timeout -1 spawn telnet -K 192.168.1.10 match_max 100000 expect -exact "Username: " send -- "$uname\r" expect -exact "Password: " send -- "$passwd\r" expect -exact "homeswitch#" send -- "exit\r" expect eof
Any suggestions? Or please ask if I was unclear
- 08-03-2010 #2
- Join Date
- Oct 2007
RE: expect script interactive read
Otherwise, you could double wrapper with the expect script in-lined into a shell script that does what you want up front reading from user's input and then passing those to the expect script as command line args.