I have a machine configured (via cron) to start a screen session on reboot. The session opens up a few screens and starts a server in one of them. All of this works fine. However, when I login and resume the screen session, I get a (PS1) prompt like this:
\u@\h [\j] \w\$
Terminal colors do not appear either. This is the
PS1 string I explicitly set in my bashrc file, but the control sequences like
\u are not being interpreted by the shell. I have ensured that my bashrc and profile get imported before the screen starts; the script called from cron:
#! /bin/bash # This script initializes screen with a propert environment. It is intended to # be run from cron. # source the profile if [ -r "$HOME/.profile" ]; then source "$HOME/.profile"; fi if [ -r "$HOME/.bash_profile" ]; then source "$HOME/.bash_profile"; fi if [ -r "$HOME/.bashrc" ]; then source "$HOME/.bashrc"; fi exec screen -dmS initscreen
I tried adding the line "
export TERM=screen.xterm-256color" and variants (e.g.,
export TERM=xterm-256color), but these changed nothing.
My assumption is that because there is not a real TTY when the screen gets started at reboot, somehow screen can't interpret my terminal correctly and ends up starting up without any terminal interpretation. When I quit screen and rerun the startup script from an ssh session (instead of from cron at reboot), everything work fine. How can I get screen to startup at reboot in a way that will let me attach it later with these terminal features working?
Thanks in advance.