1

I need to toggle logging from outside of a detached screen session. Interactively you do this by pressing ctrl-a H.

Their octal codes are \001 and \110. (source)

What I tried:

$ screen -S test

then from other terminal I tried to push these codes to the screen:

$ screen -S test -X stuff $'\\001\\110\\r'

However instead of the expected Appending to logfile screenlog.0 I got bash: h: command not found

Please tell me how to push 'Ctrl-a H' to a detached screen session.

4
  • Outh of curiosity... Why don't you reattach to the detached session and press ctrl-a H?
    – YoMismo
    Jul 7 '14 at 14:46
  • I'm running many services in screen sessions over multiple machines and I'm managing them using a wrapper script that can be called remotely. Jul 7 '14 at 14:50
  • 1
    According to the screen man page, stuff sends the string to the the input buffer of the current window, i.e. to the controlling process that is running in this window. If I understand correctly, this is not what you want.
    – vinc17
    Jul 7 '14 at 15:44
  • Have you tried -d -m? according to the manual this creates a new session but doesn't attach to it, which is what I presume you are looking for. Create a new screen detached, name it and send som commands.
    – YoMismo
    Jul 7 '14 at 15:54
4

You've injected the characters Ctrl+A, H and Return into the application (bash) running in the Screen window. The string that is passed to stuff is not parsed for Screen escapes.

screen -S test -X log on seems to work, or screen -S test -X log to toggle as you want.

1
  • I know that saying thank you is against the forum policy... but thank you :) Jul 7 '14 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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