I'm trying to break down the following plink command and modify it to allow a variable substitution.
plink.exe 192.168.1.1 --% echo """#define MYSPACE""" > /home/my/file.txt
I want to do the following, but But what follows the echo
is sent to bash verbatim.
plink.exe 192.168.1.1 --% echo """#define MYSPACE""" > /$(home)/my/file.txt
Constructing the echo
string before the plink
command doesn't work for the same reason; everything after echo
is sent verbatim. How can this be done?
On the PowerShell side, if home
is a defined environment variable, that will still be expanded after the --%
. So,
plink.exe 192.168.1.1 --% echo """#define MYSPACE""" > /%home%/my/file.txt
For additional information on how the --%
works, see "the stop parsing token" at learn.microsoft.com