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.

link|improve this question
feedback

1 Answer

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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