title: prevent expect from exiting on EOF
body: <p>I have an expect script that connects to a vpn using openconnect. The script works perfectly, except that I don't know how to keep openconnect alive once the password has been provided and expect has reached the EOF. I think I need to fork the process, but I need it to keep the password somehow. Here is my script</p>
  
  <pre><code>#!/usr/bin/expect -f
  
  spawn ./openconnect
  expect "sudo"
  send "sudo_password\r"
  expect "password:"
  send "vpn_password\r"
  expect /Connected\stun1\sas/ #expect connected tun1 as some ip
  </code></pre>
  
  <p>and openconnect</p>
  
  <pre><code>#!/usr/bin/env bash
  
  sudo -k
  sudo -S openconnect --juniper --user username --csd-wrapper ~/juniper-vpn-py/tnc vpn_server
  </code></pre>
  
  <p>The output gets to connected tun1 as some ip as expected, but then expect closes and so does the process is spawned.</p>