Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On an embedded device with BusyBox installed I want to set it up so that the gnu screen command is automatically started when any BusyBox session is started.

I have seen that I can add the screen command into the /etc/profile file but are there any other ways of doing this?

share|improve this question
    
How do you start your session? –  Gilles Aug 14 '12 at 23:49
    
Via ssh to the device. –  user22086 Aug 15 '12 at 23:11
add comment

2 Answers

If you are using ssh you can just have it run instead of the shell (the default) when you connect.

ssh -t me@host screen -RD

That will create a new session of one does not exist, or otherwise connect to an existing session.

The -t flag to ssh tells to to create a pty even though it is not starting a shell. You need that for interactive use.

share|improve this answer
add comment

Add exec screen -R at the end of ~/.profile on the device: every time you log in, your session will reattach the last-created screen session. More precisely, to avoid launching screen in non-interactive sessions where you want to read your .profile to set environment variables, use this:

case $- in *i*) exec screen -R;; esac

You will still be able to avoid attaching to screen in an interactive session by running ssh -t bash -i as this will skip your .profile.

share|improve this answer
add comment

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.