In the project, I shall boot to the Linux console mode (init 3), and then run a python script using curses library (with console UI) in a specific tty.
For example, OS boots to tty 0, and I type:
sudo chvt 2 && sudo python /root/aaa.py
This is Ubuntu Live Desktop OS, so sudo would not prompt for password and just execute the command with elevated privilage.
The tty does switch to 2, but /root/aaa.py (with curses library UI) is executed in tty 0...
If I want the script is executed in tty 2 and the UI is shown in tty 2, how to do it?
Many thanks.
I think the openvt command is what you're looking for. Remember that you'll need root privileges to execute it.