1

I am running commands remotely stuffing them into screen commands via SSH. Rather than type directly into the terminal displayed, I use remote SSH commands which are run by clicking a button in a GUI. I use the screen command because it allows me to see the terminal without having to type directly in it.

For every command executed I want the screen output to be saved to a specified file, in addition to being displayed on the terminal. Not all commands are necessarily executed by stuffing into the remote screen. The commands can be saved into a script which is uploaded to the remote computer and the screen stuff command used to run it.

How do I setup the command to save to a named file in addition to displaying the output as normal. Use of screen is a convenience but I am looking for a method which can work without screen/tmux being involved.

  • Have you looked at the script command? Or if you want a more integrated solution, maybe asciinema.org ? – Stephen Harris Jul 15 '16 at 14:02
  • 1
    despite the gui, do you do something like ssh $host screen? If it's this simple, you could just tee the output into a file – Hachi Jul 15 '16 at 14:03
  • @Hachi Is it this simple? I looked up tee and it looks like it will do what I want. I thought I asked this kind of question before and didn't get an answer. I will try it out and get back to you. – vfclists Jul 15 '16 at 18:28
1

In addition to what @Stephen Harris said, script command will write to a file but it will overwrite its contents each time you use it. Use script -a to append to it.

script will save everything in your terminal to a file.

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.