title: how to send the output of a command that runs on the connected machine, to a file in the connecting machine
body: <p>I am making a script to access a bunch of machines through ssh and run the <code>df -h</code> command to check if their disk usage is getting near 100% , my problem is that I can't run the command on the machine that when I run the command, i cant send it to a file in the machine that I am using to connect.
  I have tried this</p>
  
  <pre><code>df -h &gt; /dir/file
  </code></pre>
  
  <p>but that just creates a file in the machine I am connected to.
  How would I go about doing what I am trying to do?</p>
  
  <p>the full code that im using to do this is</p>
  
  <pre><code>expect &lt;&lt;-EOF
  spawn ssh -oPort=23 x.x.x.x df -h &gt; /home/file
  expect "*password: " {send "password\r"}
  expect "*#" {send "exit\r"}
  EOF
  </code></pre>
  
  <p>Any help is appreciated.</p>