2

I can login to the server terminal with username and password. But I can't run the screen command. It says Must be connected to a terminal while I ran this screen -R newNodeServer.

I found an answer at Ask Ubuntu: What does the script /dev/null do?, but if I run the command script /dev/null according to that answer, will the running server, websites, and applications be affected?

I am going to run some artisan commands for Laravel in screens. Such as php artisan queue and php artisan websockets:serve

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
test team
  • 123
  • 4
  • I myself would be asking the more obvious question _Why, if I am logged in to a terminal, is the computer saying that I am not connected to a terminal?_. – JdeBP Dec 10 '19 at 11:05
  • @JdeBP, That's I already running with the terminal – test team Dec 10 '19 at 13:04
  • I cannot make any sense of that sentence. – JdeBP Dec 10 '19 at 13:42
  • @JdeBP because older versions of `screen` will try to open the current terminal _via its path_, and that may not work on Linux: it's the same problem as with `su other_user -c 'cat /dev/stdout'` or `su other_user -c 'cat /dev/tty'`, etc. –  Dec 10 '19 at 15:54
  • 4
    Maybe check the answer to that same Q on _this_ site: [What does 'script /dev/null' do?](https://unix.stackexchange.com/questions/511267/what-does-script-dev-null-do) –  Dec 10 '19 at 15:57
  • And no, running `script /dev/null` will not affect your websites, applications or finances; it just creates another pseudo-tty, just like `screen` itself does. –  Dec 10 '19 at 16:09
  • Don't tell me. Tell the person with the problem. I'm just explaining what the better question to ask is. – JdeBP Dec 13 '19 at 17:37

1 Answers1

1

My best guess here is:

  1. @testteam is trying to run screen command and getting screen complaining about not being able to open terminal.
  2. In the answer linked, solution mentioned is to use script /dev/null and that should resolve the issue.
  3. @testteam is wondering if that's going to affect any servers running on the machine (probably in the screen session).

This answer has very good explanation what script command is going to do and why screen is complaining:

Why this works is invoking script has a side effect of creating a pseudo-terminal for you at /dev/pts/X. This way you don't have to do it yourself, and screen won't have permission issues - if you su from user A to user B, by directly invoking screen you try to grab possession of user A's pseudo-terminal. This won't succeed unless you're root.

So the fact that script solves the issue with screen is basically side effect. I'm guessing that you want to run some node.js app in the screen session. The fact that you created pts device and used script for that should not affect servers or (web)apps running inside screen session.

pbm
  • 24,747
  • 6
  • 36
  • 51
  • I am going to use the screen for artisan commands. So see the updated question, please – test team Dec 10 '19 at 16:09
  • And what's about the last part of the linked answer(https://serverfault.com/a/255531/86410) "This won't succeed unless you're root. That's why you see the error message."? – test team Dec 10 '19 at 16:14
  • _Newer version_ of `screen` are perfectly able to "grab posession" of the terminal without being root. I don't think that the answers you link to do such a great job explaining why older versions of `screen` aren't able to do it. –  Dec 10 '19 at 16:16