I have written a bash script which calls other process (the ones that ask for password on terminal).
#!/bin/bash
source pc.txt
snp_pw=$export_snapshot
export snapshot_pw=snp_pw
echo_time() {
date "+%d:%b:%Y:%H:%M:%S"
}
# Export Snapshot
echo "$(echo_time) :STARTING EXPORT SNAPPSHOT SCRIPT" | tee -a ${mail_log}
loop_var=3
echo "$(echo_time) :ON FAILURE TRY AT MAX ${loop_var} ATTEMPTS" | tee -a ${mail_log}
i=1
while [ "${loop_var}" -gt 0 ]; do
expect <(cat << 'EOD'
spawn $::env(Snp_Script_Path)/export_service_instance.sh bootstrap Export_Files/test.bar
expect "Enter RPD Password:"
send -- "$::env(snapshot_pw)\r"
expect "Re-enter RPD Password:"
send -- "$::env(snapshot_pw)\r"
interact
EOD
) &> ${export_snapshot_log_location}
Instead of directly hardcoding the password here, how can I read it from within a variable in other file?
It has to be a bash and expect both. I am currently trying to read the file through source and $pass gives password. But within expect, it is not working.
I don't want to encrypt/encode anything. I just want to keep it simple.