Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So, if i do this:

su -c 'screen -dmS screenname script to run' - user to run as

It won't work. The screen command is working if excecuted from root, so there is no problem there.

If I do:

su - user
screen

I get:

Cannot open your terminal '/dev/pts/0' - please check.

What is wrong?

EDIT: I've been searching around and can't seem to find any good solution to this problem.

I'll be going for the next best thing: running the screens as root.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The reason is that when you login, you get a tty which in your case is currently called /dev/pts/0. You are the only one with access to that tty, otherwise other users could mess with your session while you're working. (Root, of course, also has access, because root always has access to everything.)

When you su to someone else, you still keep your own tty - because that's where your stuff will be shown. But now you want the other user you're su-ing to be able to take over your tty and start showing their own stuff in it.

If you trust everybody else on the server, or at least the other user you're suing to, you can make your tty writable for all, or add yourself and that other user to a group and make it writable for that group. Or you could start the screen as yourself and then su from within it instead.

share|improve this answer
    
You could also have a look at the multiuser and addacl facilities, maybe sudo to the other user and start screen detached, and then attach to it. –  Jenny D Sep 28 '12 at 9:36
    
So it would work if I use sudo insted of su? –  totokaka Sep 28 '12 at 9:44
    
Sorry, I miswrote. Sudo is just a way of running things as root or other users without having their passwords, it doesn't alter the tty problem. –  Jenny D Sep 28 '12 at 9:53
    
Hmm, do you know a way to bypass the tty problem? chomd o=rw /dev/pts/0 ? –  totokaka Sep 28 '12 at 9:57
    
That should do it - provided you trust everybody else who has access to that server. –  Jenny D Sep 28 '12 at 10:28

You can run your screen this way:

script -q -c "screen -RD" /dev/null

share|improve this answer
    
"screen -RD" is my way of running screen –  RJS Sep 28 '12 at 12:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.