Example:
I log on my laptop machine (Ubuntu 14.04) via ssh and I need to make a .log file of some command output and than transfer it to my desktop machine. The command has -o
option to redirect the output to a file. I could than just copy the file with scp
command.
The question is: Can redirect the output directly to my machine, without the need to first make a file on laptop and than transfering it with scp
?
Both machines use Ubuntu 14.
Depend on your command you can do something like this:
the log will be saved in your machine, a real example:
If your command does not supports outputs to
stdout
then run it like this:If you want to see what are typing and output at the same time - try it:
I have a similar requirement except I need to be able to "turn on" the output to local pipe/process after logging in and setting things up. I don't want all the login text getting put into the local file/pipe.
Basically, I need to ngrep from a remote machine, and pipe the output to a local test script that checks the network traffic for certain things. Also, when the test is running, I don't want to mix outputs which would happen if I used tee. I'd see the output from the ngrep, PLUS the output from the test which would be confusing. Also, directly redirecting to a file > filename would mean the login process would all be redirected to the file and I wouldn't be able to see what was going on.
This is for a demo so it has to be clear to the audience what is going on.
Bzzzt!!! Wrong! Doesn't work that way
If it weren't for the need for sudo with ngrep, this wouldn't be a problem. I can't really chmod a+s ngrep without bringing devops down on my case hard.