openconnect fails to keep running in the background in a terminal that's closed

336 Views Asked by At

This is a spin-off from other post.

This command retrieves a password from keepassxc, prints it as stdin to an openconnect (for VPN connection) command, and the process goes to the background.

sh -c 'pass=$(keepassxc-cli show -a password my_keepass_DB my_ENTRY) && printf "%s\n" "$pass" | sudo openconnect --background --protocol=gp https://my.url --user=my_NAME --passwd-on-stdin'

Now, I would like to bind this command to a key using .xbindkeysrc, for which we need to prepend gnome-terminal -- (and double-quote the whole line):

"gnome-terminal -- sh -c 'pass=$(keepassxc-cli show -a password my_keepass_DB my_ENTRY) && printf "%s\n" "$pass" | sudo openconnect --background --protocol=gp https://my.url --user=my_NAME --passwd-on-stdin'"

But it seems that openconnect --background fails to keep running in a terminal that's closed; namely there is an problem with vpnc-script, shown in lines 2,5-7:

enter image description here

Question: How to run this command within a terminal that exits after the command is run, so that openconnect keeps running in the background?

0

There are 0 best solutions below