我写了一个厨师食谱,它将获取密码并提供一些输出。所以我使用bash块来调用expect并使用send命令获取密码,代码如下所示 -
bash "Update Schema #2 Passwords" do
user "#{prod_user}"
group "#{usergroup}"
code <<-EOH
export RETAIL_HOME=#{retail_home}
cd #{retail_home}/orpatch/#{product_wallet}
/usr/bin/expect -c 'spawn ./update-rase01_db.sh
expect "Enter the username to associate with rase01_db (this can be the existing username or a new username):"
send "#{schema2_username}\r"
expect "Enter your secret/Password:"
send "#{schema2_password}\r"
expect "Re-enter your secret/Password:"
send "#{schema2_password}\r"
expect "Enter wallet password:"
send "#{wallet_password}\r"
expect eof'
EOH
end
当我运行这个食谱时。我得到以下输出 -
bash[Update Schema #2 Passwords] action run
[execute]
Note: when prompted for your secret/Password, enter the NEW value you want to use.
Enter the username to associate with rase01_db (this can be the existing username or a new username): RASE01
Running /u01/app/oracle/product/12.1.0/client_1/bin/mkstore -wrl /u01/projects/rase/retail_home/orpatch/orase_wallet -modifyCredential rase01_db RASE01
Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
Your secret/Password is missing in the command line
Enter your secret/Password: Welcome1
Re-enter your secret/Password:
Enter wallet password:
oracle.security.crypto.core.CipherException: Invalid padding string (or incorrect password)
- execute "bash" "/tmp/chef-script20170120-4085-jw5ynw"
所以我的理解是在第一个提示中,即#34;输入你的秘密/密码&#34;它接受密码,只为{Enter Key stroke}提供下一个提示的值,即#34;重新输入您的密码/密码:&#34;因此密码不正确并失败。
请给我一些建议或选项来解决这个问题。
工作一轮以避免厨师中的Expect阻止 -
bash "Update Schema #2 Passwords" do
user "#{prod_user}"
group "#{usergroup}"
code <<-EOH
export RETAIL_HOME=#{retail_home}
cd #{retail_home}/orpatch/#{product_wallet}
echo #{schema2_username} >> passwd
echo #{schema2_password} >> passwd
echo #{schema2_password} >> passwd
echo #{wallet_password} >> passwd
./#{rase_schema_update} < passwd
rm -rf passwd
EOH
end
但我仍然在寻找一个解决方案,为什么我无法获得期望的密码。