title: Execute commands on SSH server using plink.exe in .bat file
body: <p>I am very new to batch scripting and have the following in a batch file:</p>
  <pre><code>echo off
  setlocal
  
  SET cluster=&quot;cluster&quot;
  
  ( 
      cd &quot;C:\path&quot;
      python script.py -nodes %cluster% -type worker -index 1 -batch 64 &gt; log.log 2&gt;&amp;1
  ) | plink.exe -ssh user@host -pw password 
  
  cd &quot;C:\path2&quot; 
  python worker.py -nodes %cluster% -type worker -index 0 -batch 64 &gt; log.log 2&gt;&amp;1
  pause
  </code></pre>
  <p>However, something's up with:</p>
  <pre><code>( 
      cd &quot;C:\path&quot;
      python script.py -nodes %cluster% -type worker -index 1 -batch 64 &gt; log.log 2&gt;&amp;1
  ) | plink.exe -ssh user@host -pw password 
  </code></pre>
  <p>It does not seem like the python file runs on the remote server (or if it is, the log file is not saving). In addition, plink.exe gives me some weird output-- the below is what I see:</p>
  <pre><code>Using username &quot;user&quot;.
  [2J[?25l[m[H
  
  [H]0;c:\windows\system32\cmd.exe[?25h[?25lMicrosoft Windows [Version 10.0.18363.1377][9X[9C
  (c) 2019 Microsoft Corporation. All rights reserved.
  [52X[52C
  user@host C:\Users\user&gt;[10X[10C[4;43H]0;Administrator: c:\windows\system32\cmd.exe[?25h
  ^
  </code></pre>
  <p>I also get the above output if I were to <code>plink.exe -ssh user@host -pw password</code> on cmd.exe.</p>
  <p>However, I am more interested in understanding why the commands</p>
  <pre><code>cd &quot;C:\path&quot;
  python script.py -nodes %cluster% -type worker -index 1 -batch 64 &gt; log.log 2&gt;&amp;1
  do not seem to be executed on the server.
  </code></pre>
  <p>The commands</p>
  <pre><code>cd &quot;C:\path2&quot;  
  python worker.py -nodes %cluster% -type worker -index 0 -batch 64 &gt; log.log 2&gt;&amp;1
  </code></pre>
  <p>seem to work fine as I see a log file being saved. It is the commands when sshing that do not.</p>