"Must be connected to a terminal error" with screen -x command on a Linux Container
Asked Answered
A

4

11

I am using Linux containers with Proxmox 4. When I am connected on an Ubuntu 16.04 container with:

pct enter <id>

I run a script with screen and try to watch the process running with:

screen -x <processname>

I got the error:

Must be connected to a terminal error

When I connect with:

ssh -t <user>@<container_ip>

It works, I can attach the display to the screen.

How can I use screen -x when I am connected with pct enter ?

Appetency answered 13/9, 2016 at 13:24 Comment(2)
Not clear what -x provides you. Did you try screen -t -x .. ? Good luck.Glister
screen -x allow to display a background script launched with the screen command. When I use the command screen -t -x I got the same error : Must be connected to a terminal.Appetency
C
17

I found a solution that works for same case(https://www.svennd.be/screen-in-lxc-attach)

Execute this

script /dev/null

Then you can run screen, et voila

Chappy answered 29/5, 2017 at 14:4 Comment(2)
That does not explain what the cause of the problem is, though; it merely bodges around it with a pseudoterminal.Thinia
What is does? I dont understand how it allows starting screen session?Errolerroll
G
7

This is happening mostly because of the reason that you must have switched user to the current terminal user using the command sudo su or user changing command. You will need to own the shell on which you are working. You can do so by running this: script /dev/null.

Alternatively, You can restart the terminal session with the user(which was used when creating screen) and not coming to current user using switch user commands.

To know active screens : screen -list

Goofball answered 3/8, 2017 at 11:5 Comment(1)
This explanation makes no sense at all. script is not a command for owning a shell, and sudo is unrelated to a lack of a controlling terminal because it does not adjust the controlling terminal.Thinia
P
0

I followed this solution by issuing

screen -d -m <command ...>

Then I get a new error saying

Cannot make directory '/var/run/screen': Permission denied

I then search and found a workaround here

Now I can execute screen -d -m successfully.

Thank you all.

Pastelki answered 15/11, 2023 at 5:8 Comment(0)
L
-4

Alternatively, You can start the session within "hohup" and send to background

Laminar answered 30/12, 2020 at 20:28 Comment(2)
Welcome to StackOverflow. Did you mean nohup instead of hohup? Please edit your answer to fix.Gemology
Welcome to Stackoverflow, to maximise your chance of getting your answer accepted and upvoted, please Take the tour and read How do I write a good answer.Cumine

© 2022 - 2024 — McMap. All rights reserved.