3

Suppose I opened up a screen to run some program that outouts some result.

Once the program finishes, is there a way to get the result in the screen from outside.

For example:

  1. I opened up a screen using "screen -S myscreen"
  2. I detached from the screen
  3. The program in screen finishes
  4. I want the result in the screen by command like screen --get-result-from myscreen

PS:

I am currently deploying a distributed task over several machines. I need someway to get the result without visiting each screen individually.

UPDATE:

Any way to copy part of the content in screen? As there might be other irrelevant information.

  • 5
    screen -S myscreen -X hardcopy some-file would save the content of the screen to a file. You could also use logging. – Stéphane Chazelas Dec 1 '14 at 17:24
  • What if I want to copy only a part of the useful information? Any way to do that? – xiaohan2012 Dec 1 '14 at 19:44
  • 2
    Why not have the process that you're running log itself? Or if you want only, say, the last 20 lines of output, then /path/to/myscript.sh arg arg arg | tail -n20 > /path/to/process_log.txt – DopeGhoti Dec 1 '14 at 20:32
  • Interactively you can do it by marking part of the screen, copying it to the paste buffer, and then writing this to a file, but there doesn't seem to be a way to script this. Looks like you'll have to write the whole screen to a file, and then edit it from there. – Barmar Dec 4 '14 at 6:00

Your Answer

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

Browse other questions tagged or ask your own question.