Entering SSH passwords using mixed Batch/Jscript script

76 Views Asked by At

im trying to automate a ssh connetcion to a NAS in order to wake up a computer using WOL. All goes fine until i try to enter the root password required for the wake command

start cmd.exe @cmd /k "ssh [email protected]"
ping localhost -n 2
%SendKeys% "xxxxxxxxxx"
%SendKeys% "{ENTER}"
ping localhost -n 5
%SendKeys% "sudo synonet --wake xx:xx:xx:xx:xx:xx eth0"
%SendKeys% "{ENTER}"
%SendKeys% "xxxxxxxxxx"
%SendKeys% "{ENTER}"

this is the result of the above code

strange enough, the ssh password is entered correctly but calling %SendKeys% "{ENTER}" after the wake command cause strange excape characters entered causing the command to fail. Is there some way to avoid this side effects? Thanks in advance.

i tried the code above but i cannot figure out why it displays strange characters.Also other methods like putty are useless because cannot automatically enter the root password after the command.

0

There are 0 best solutions below