Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use a shell script to supply a password when the interface asks for it
    text
    copied!<p>I have a script(<strong>dobrt</strong>) which upon executing asks for a password.How can i write a script which executes <strong>dobrt</strong> and automatically supplies the <strong>password</strong> it asks for.</p> <p>when i execute <code>./dobrt -p file.txt</code> , the system asks for a password. I want the password to be sent in automatically by the script. Here is the output</p> <pre><code>$ ./dobrt -p file.txt Found 194 tests to execute ------------ 2010 February 11 11:27:33 ------------ Password: *************** </code></pre> <p>I tried using shell and expecxt scripts for this. here is what i did.</p> <p>I have 2 scripts. I call the second script(run_dobrt.exp) from the first one(run_dobrt.sh).</p> <p><strong>Script 1 : run_dobrt.sh</strong></p> <pre><code>#!/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` </code></pre> <p><strong>Script 2: run_dobrt.exp</strong></p> <pre><code>#!/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 </code></pre> <p>Now when i run run_dobrt.sh i get the following error <strong>run_dobrt.sh[20]: spawn: not found</strong> How to get rid of this error and get this task done? Please help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload