ssh user@host.com "ls -l" >output
You can even do things like:
ssh user@host.com "cat foo.tar" | tar xvf --
To make things simple, create a pub / private key pair using ssh-keygen. Copy the * .pub key to the remote host in ~ / .ssh / authorized_keys, make sure it's chmod'd 600
Then you can do
ssh -i ~ / .ssh / yourkey user@host.com ... etc.
And he will also not ask for a password. (If your key pair is without password).