paramiko/paramiko — pull request #245 by redixin (2013-12-31 15:02:59+00:00)
Title: Add run method to client

Try to run with paramiko script like this:

```bash
while true
do
echo "some stdout"
echo "some stderr" >&2
done
```

Example from README will not work.

For running commands with big amount of mixed stdout/stderr data, lots of code needed.

This method make such things more simple.

Sample usage:
```python
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('example.com', username='user')

exit_status = client.run('script.sh', stdout=open('/tmp/temp_stdout', 'w'))
```

Also pseudo files can be passed:
```python

class PseudoFile(object):
def write(self, data):
print 'chunk received:', data

exit_status = client.run('script.sh', stderr=PseudoFile())
````

Also StringIO objects works well.

More examples:

Run local script on remote side:
```python
client.run('sh -s', stdin=open('/tmp/local_script.sh', 'rb'))
```

Remote grep:
```python
client.run('grep sample',
stdin=open('/tmp/local_data', 'rb'),
stdout=open('/tmp/grepped_data', 'w'))
```