I have a expect script written to perform a login operation. The login requires the 2fa code, this code can be obtained by executing the shell command 2fa my_login
. Now how do I execute the 2fa command and pass it's output to the send of my script?
I need to do something like send -- "$(2fa my_login)"
. The output of the $(2fa my_login) should be passed to the send.
My script
#!/usr/bin/expect -f
set timeout -1
spawn /home/local/apps/forticlientsslvpn/64bit/forticlientsslvpn_cli --server vpn.vpn-domain.com:10443 --vpnuser user-id
expect "Password for VPN:"
send -- "pass\n"
expect "Enter the time-based OTP generated in your device."
send -- "$(2fa my_login)\n"
expect eof