How to use a linux expect script to enter answer a prompt for password

前端 未结 4 414
忘掉有多难
忘掉有多难 2021-01-19 00:05

I am having some trouble writing a script that will launch my forticlient vpn command line client and send my password when it is prompted. Here is my code:



        
4条回答
  •  无人共我
    2021-01-19 00:41

    #!/usr/bin/expect -f
    set timeout -1
    cd /usr/local/forticlientsslvpn
    spawn ./forticlientsslvpn_cli --server myhost:10443 --vpnuser myuser
    expect "Password for VPN:" {send -- "mypassword\r"}
    expect "to this server? (Y/N)\r" {send -- "y\r"}
    
    expect eof
    

提交回复
热议问题