If you use this command, it will execute the command on the remote end:
Quote:
ssh username@server cat filename
However, if you pipe the output through to another command, THAT PART will be processed locally, and the outputfile will also be in the local directory, like this:
Quote:
ssh username@server cat filename | grep blahblah > outputfile
You put the SSH-statement on a single line, which indeed will wait for your input and hold execution of the remaining script, until you exit the SSH-session.