title: Using ssh to login to linux terminal from windows and run command in a logged in shell
body: <p>First of all, this may seem like a duplicate question but I have searched stack overflow/various other forum sites and still haven't managed to find a solution.</p>
  <p>A few example forum posts I have reviewed to prove I've done my research before asking a question:</p>
  <ul>
  <li><a href="https://superuser.com/questions/130443/remotely-run-script-on-unix-get-output-locally">https://superuser.com/questions/130443/remotely-run-script-on-unix-get-output-locally</a></li>
  <li><a href="https://linuxconfig.org/executing-commands-remotely-with-ssh-and-output-redirection" rel="nofollow noreferrer">https://linuxconfig.org/executing-commands-remotely-with-ssh-and-output-redirection</a></li>
  <li><a href="https://zaiste.net/posts/few-ways-to-execute-commands-remotely-ssh/" rel="nofollow noreferrer">https://zaiste.net/posts/few-ways-to-execute-commands-remotely-ssh/</a></li>
  <li><a href="https://unix.stackexchange.com/questions/474533/get-output-of-this-command-from-another-server-via-ssh">https://unix.stackexchange.com/questions/474533/get-output-of-this-command-from-another-server-via-ssh</a></li>
  <li><a href="https://stackoverflow.com/questions/18522647/run-ssh-and-immediately-execute-command">Run ssh and immediately execute command</a></li>
  <li><a href="https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/" rel="nofollow noreferrer">https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/</a></li>
  </ul>
  <p>There's hundreds more but I won't include them all.</p>
  <p>I essentially need a shell script to open a command prompt on windows, login to a remote linux system and run a command.</p>
  <p>I am aware this can be done with the following:</p>
  <pre><code>start cmd /k ssh user@host ls
  </code></pre>
  <p>But the problem with the above is that the ssh connection is closed upon completion of the task.
  I am also aware I can keep the ssh connection open by adding:</p>
  <pre><code>bash -l
  </code></pre>
  <p>in some cases.</p>
  <p>For my use case, I need to run a launch file for ROS (robot operating system) and for this I need to see the output from the command.</p>
  <p>And when attempting to run roslaunch launchFile.launch (in place of ls above):</p>
  <pre><code>start cmd /k ssh user@host &quot;roslaunch launchFile.launch&quot;
  </code></pre>
  <p>the command prompt returns</p>
  <pre><code>bash: roslaunch: command not found
  </code></pre>
  <p>I've obviously sanitised the specific name of my launch file but</p>
  <pre><code>roslaunch launchFile.launch
  </code></pre>
  <p>runs perfectly if I login to the linux PC first:</p>
  <pre><code>ssh user@host
  </code></pre>
  <p>then run the command.</p>
  <p>I have achieved this exact use case on MacOS but I now need reimplement the same solution on windows:</p>
  <pre><code>osascript -e 'tell app &quot;Terminal&quot;
       do script &quot;ssh quantum@172.23.199.1 \n
       roslaunch launchFile.launch&quot;
  end tell'
  </code></pre>
  <p>Thanks in advance for any help or advice.</p>