expect auto input message for cmd

Submitted by lepton on Fri, 07/10/2020 - 13:22

#!/bin/bash
echo -n "Enter Pass:"
read -s my_pass
cmd_name="/bin/somecmd"

expect << EOF
set timeout 100
spawn "$cmd_name"
expect {
    "Enter password:" { send "$my_pass\r";exp_continue }
}
EOF

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.