Reputation: 770
I have a bash script that automatically connects to a remote location and runs another script that is stored at the remote location. In the script on the remote location, I want to have my autoconnect script (which is stored on my local pc) capture specific output that is echoed out from the remote script so I can store it in a separate log. I know that something will need to be placed on the remote script that redirects the output so the local script can catch it, I'm just not sure where to go. Help is appreciated!
Upvotes: 0
Views: 175
Reputation: 75568
On your local script, in your ssh line, you can redirect some of the outputs to a file with tee
:
ssh ... | tee -a output.log
If you want to filter which one goes to the output.log file, you can use process substitution:
ssh .... | tee >(grep "Some things you want to filter." >> output.log)
Besides grep you can use other commands as well like awk.
Upvotes: 2