I have a script ( dobrt ) that asks for a password after executing the request. How can I write a script that does dobrt and sends the password automatically.
when I execute ./dobrt -p file.txt , the system asks for a password. I want the password to be sent automatically using a script. Here is the conclusion
$ ./dobrt -p file.txt Found 194 tests to execute ------------ 2010 February 11 11:27:33 ------------ Password: ***************
I tried using shell and expecxt scripts for this. here is what i did.
I have 2 scripts. I call the second script (run_dobrt.exp) from the first (run_dobrt.sh).
Script 1: run_dobrt.sh
#!/bin/ksh TESTCASE_HOME="/home/abhijeet/code/testcases"; TESTCASE_LIST="file.txt"; PASSWORD="*****"; echo "Running Expect Script" `./run_dobrt.exp $TESTCASE_HOME $TESTCASE_LIST $PASSWORD`
Script 2: run_dobrt.exp
#!/usr/local/bin/expect -f set TESTCASE_HOME [lindex $argv 0]; set TESTCASE_LIST [lindex $argv 1]; set PASSWORD [lindex $argv 3]; set timeout 200 spawn $TESTCASE_HOME/dobrt -p $TESTCASE_HOME/$TESTCASE_LIST expect "*?assword:*" {send -- "$PASSWORD\r";} expect eof
Now, when I run run_dobrt.sh, I get the following run_dobrt.sh error [20]: spawn: not found How to get rid of this error and complete this task? Please, help.
shell expect
Abhijeet Feb 11 '10 at 6:16 2010-02-11 06:16
source share