0

Using a simple Bash script in Ubuntu 20.04, I am trying to let it create a new Gnome terminal tab, then run an interactive Python script inside a LXC container my_lxc.

#!/bin/bash
cmd="python interactive_foo.py"
gnome-terminal --tab -- lxc exec my_lxc -- "$cmd"

and

#!/bin/bash
cmd="python interactive_foo.py"
gnome-terminal --tab -- bash -ic "lxc exec my_lxc -- \"$cmd\""

However, when I run either bash script, I notice a new terminal tab opens and closes quickly.

The new terminal tab should remain open and allow me to interactive with interactive_foo.py. How can we do this?


Also, when on the LXC host, running the following does not do/output anything:

lxc exec my_lxc -- "python interactive_foo.py"
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
  • Your question seems to be a duplicate of https://stackoverflow.com/q/3512055/6770384. – Socowi Sep 30 '21 at 19:20
  • @Socowi I think my `lxc exec` command might be the main problem. Updated the question – Nyxynyx Sep 30 '21 at 19:42
  • Right, maybe the `lxc` part needs a slightly different solution. But right now I suspect the python script to be the actual problem. If you use `cmd="sleep 100"` does the tab stay open? If so, then your python script may exit prematurely and has to be adapted. – Socowi Sep 30 '21 at 20:12

0 Answers0