On Thu, Jul 23, 2020 at 3:58 PM Tassilo Horn <t...@gnu.org> wrote:

> My actual use-case is a script that will eventually call openconnect to
> establish a VPN connection to my work network.  During my work day, I'll
> mount several samba shares from that network and usually I forget to
> umount them before C-c-ing the script.  Then the system shutdown will
> hang because the system tries to umount them which won't work without
> VPN connection.  So I want some mechanism to umount those shares
> _before_ the VPN connection is closed.
>

This is a good use case for Expect, I think. Something like

```tcl
#!/usr/bin/env expect

spawn openvpn ...
expect Password
send -- "$password\r"
# any other prompts before the connection is made...

interact {
  \x003 {
    # user hit Ctrl+C
    foreach mount {/mnt/a /mnt/b /mnt/c} {
      puts "unmounting $mount"
      exec umount $mount
    }
    send \x003   ;# send the Ctrl+C to openvpn
  }
}
puts "bye"
```

-- 
*Glenn Jackman*
Senior Software Developer

*Pythian - Love your data*
jack...@pythian.com
Tel: +1 613 565 8696 Ext. 1478
Mobile: +1 613 808 4984
www.pythian.com

-- 


--





_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to