Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to script the spawning of GNU/screen windows by using commands of the form screen <CMD>.

For some reason when I start GNU/screen (by hand), the shell that it starts in window 0 (/bin/bash) does not contain a $STY environment variable. Without this commands like screen vim start a nested screen session, not another window as I want.

My environment is somewhat unusual. Here's how I end up in it:

ssh robm@somehost
sudo su sharedaccount
script /dev/null
screen

The script /dev/null step exists because the TTY device allocated for the robm user cannot be accessed by the sharedaccount user. The script command allocates a new TTY that is owned by the user that invoked it, solving that problem.

If I skip the sudo and script steps, GNU/screen sets $STY just fine. In other words this works just fine:

ssh robm@somehost
screen

Presumably something about sudo and script interferes with screen, but I'm stumped as to what.

share|improve this question

2 Answers 2

Gah, it was the sharedaccount SHELL init script's fault. It was calling exec env -i ... to create a new shell without cruft from the original user's environment.

Sorry if I wasted anyone's time.

share|improve this answer

I think you could both skip the script /dev/null step and fix your issue if you changed your call to su by issuing it with a dash, like: sudo su - sharedaccount. This would set all your environment variables mostly the way they would be if you'd actually logged in as sharedaccount.

share|improve this answer

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.