1

How do I disable the output when you are done with a screen from the screen command?

Example:

function foo()
{
    echo "Testing..."
    sleep 2
    echo "Done!"
}
export -f foo
screen -q bash -c "foo" &> /dev/null

It all works as expected, however I cannot find out how to disable the "[screen is terminating]".

  • 3
    Screen runs detached from your terminal, so you can't use the pipe like you would expect, this won't work for example: screen -q bash -c "foo" | head -n -1 &> /dev/null. So the real question is why do you care about this one line of text? If you can answer that, then maybe we can find a solution to that problem. – totaam Dec 31 '11 at 19:28
3

There are only two solutions that I can think of. The first is to modify the screen code itself and recompile. The second is to have something like an expect wrapper around the program (untested):

#!/usr/bin/expect -f
spawn screen -q bash -c foo
interact {
    "\[screen is terminating]" exit
}
1

The screen is using your tty to write that text, so you can't stop the screen to write that text by just redirect stdout or stderr to the /dev/null.

I have the simplest way for removing that line from an output.

In this approach you need to move the cursor upward and clear that line. Escape characters can help you with that, for example,to execute the screen command with cat command, you need to execute that like:

screen cat;echo -en '\e[A\e[K'

This will remove the line [screen is terminating].

  • 2
    Better as printf '\33[A\33[K' is many echo implementations don't support -n or -e (Unix compliant ones would need echo '\33[A\33[K\c'). Or use tput cuu1; tput el to avoid hardcoding the sequences of a specific terminal. – Stéphane Chazelas May 5 '17 at 11:50
0

Simple :D

The only way is to modify the "screen" executable. The best (portable) way to do so is something like this:

offset=$(tr -c '[[:print:]]' '\n' <`which screen`|grep -b "screen is terminating" | cut -d ":" -f 1)
printf "\x00" | dd of=`which screen` obs=1 seek=$offset conv=notrunc

obviously the script must be re-run every time the package is updated.

  • 1
    sorry I was in a rush...I'll update it now. – Zibri Dec 20 '18 at 19:54

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.