Re: [Fish-users] How to use functions with --on-signal properly?
Status: Beta
Brought to you by:
liljencrantz
|
From: Tassilo H. <ts...@gn...> - 2020-07-24 19:40:10
|
Glenn Jackman <ja...@py...> writes:
Hi Glenn,
> This is a good use case for Expect, I think. Something like
Oh, I didn't know it so far but the below looks promising.
> ```tcl
> #!/usr/bin/env expect
>
> spawn openvpn ...
> expect Password
> send -- "$password\r"
Does
expect Foo
prompt for Foo and automatically bind what was typed to a variable $foo?
> # 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"
> ```
Thanks,
Tassilo
|