The need for this arose from the script below. It connects to a remote PC using anyconnect's vpn utility. First it asks for the one-time-password, connects, starts an RDP client and disconnects after the RPD client app has been closed.
if [ $# == 1 ]; then
ONE_TIME_PWD=$1;
else
printf "Enter the one-time password: ";
read ONE_TIME_PWD;
fi
vpn -s connect <domain> << EOF
<user>
<pin>$ONE_TIME_PWD
EOF
# Use some RDP client here like xfreerdp or rdesktop
vpn -s disconnect <domain>
The problem is that one-time-password may change during the execution of vpn -s connect <domain>
. So I was curious whether it's possible to change the script so that it lets me enter the one-time-password after <pin>
has been inserted automatically? I've tried it with head -c -1
to remove the last newline char but the input was still finished. Any other solution not based on EOF is acceptable.