I'm SSHing to a Windows machine with
Paramiko and I'm stressed out by how hard it is to write a command because:
cmdprompt console, which has limited functionality so I need PowerShell, meaning I should prefix the command with
pwsh -c "the command"
cmdprompt doesn't support multi-line nor multiple commands naturally, so I need to stick in caret
&&s in the command.
- the command I'm calling Python with
python -c 'print("hello")\nprint("world")', however I'm already using
pwsh -c "the command"meaning I need to escape it with backticks
This is fiendishly complex and ugly, the code is a mess, it's Python and PowerShell and cmd prompt special characters intertwined at once. I'm almost 100% sure I'm missing something and there is an easier way to do it hence I'm asking whether Paramiko can run do
exec_command in PowerShell by default.