I am writing a Bash Script wherein I need to run some set of commands on a remote Linux server from my local computer using SSH. I want the results to be displayed on the terminal screen or dump the results in a file on my local system.
How can achieve this? Is the following syntax correct?
\#!/bin/bash
.
.
.
.
ssh <user>@<remote_host> 'COMMAND >> /path/to/file ; scp /path/to/file <user>@<local_host>:<location>; exit'
.
.
Thanks in advance.
Best Answer
To have the results display on the terminal screen:
To have the results saved to a file:
To have the results both displayed on the terminal screen and saved to a file: