-1

this supposed to be very basic. I'm running plink from windows and want to get some output to a file plink 192.168.229.128 -ssh -l root -pw password runsql.sh > result.log

the runsql.sh output is something like

121211212
213212312
434234234
521312312

however the result.log shows as:

121211212213212312434234234521312312

How can I fix this? thanks a bunch!

joeyy27
  • 21
  • 1
  • 7

1 Answers1

0

You seem to have opened unix line ending file in notepad.exe or some low-end editor, that does not understand line endings.

If you are always going to check the result in this manner, you can try adding this at the start of your script:

[ "$SSH_CONNECTION" -a  ! -t 1 ] && exec 1> >(sed 's/$/\r/')

Note that there should be a better & more robust mechanism to do detect that the output is being redirected over ssh session.

anishsane
  • 20,270
  • 5
  • 40
  • 73