3

In Linux

ssh me@server "echo this ran remotely"

The output this ran remotely is put to standard out. This is perfect.

In Windows

echo "echo this ran remotely" > test.cmd
putty -i privatekey.ppk -m test.cmd -ssh me@server

The output doesn't go to standard out, it opens in a new process and, as far as I can tell, is lost forever.

How do I capture the output of the remote command?

I know I can do it in cygwin, but that's not helpful because it's hard to run cygwin commands programmatically from other scripting languages.

2
  • Why not enable session logging to a log file? (On session window right-click menu bar > Change settings.)
    – Karan
    Apr 7, 2015 at 19:45
  • Another solution I found was the new ubuntu command in windows (See the windows store for "Ubuntu")
    – Jonathan
    Nov 8, 2018 at 21:36

1 Answer 1

5

This is what Plink is meant for:

plink user@host "echo this ran remotely"
4
  • Are you asking a question or answering a question. Please elaborate why this answers the question. Include sources which back your claim.
    – CharlieRB
    Apr 7, 2015 at 21:55
  • Do you know if there's a place I can put the private key file so I don't always have to specify it with the -i argument?
    – Jonathan
    Apr 7, 2015 at 21:58
  • 1
    @JonathanLeaders No. There's no equivalent of ~/.ssh/id_rsa in PuTTY toolset. Though you can use Pageant - authentication agent. Apr 8, 2015 at 6:22
  • unfortunately plink with ssh cant work for some reason.
    – GeneCode
    Nov 8, 2018 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.