linuxpowershellputtyplink

Expanding variables in Powershell, to Linux commands


On the following Powershell script:

$Project_number = Read-Host -Prompt 'Input your Project Name ie. 02XXX'
$Project_code = Read-Host -Prompt 'Input your Project Code in capita letters ie. CRE'

plink -load profile1 -batch 'setfacl -Rm d:g:user1:rwX,g:user1:rwX "/FILES/projects/$Project_number $Project_code" && find "/FILES/projects/$Project_number $Project_code" -maxdepth 1 -exec setfacl -m d:g:user1:r-X,g:user1:r-X {} \;'

How can I make plink (connected via SSH to a Linux fileserver) expand the variables $Project_number and $Project_code within the plink command.

At the moment they don't and I receive an error:

plink : setfacl: /FILES/projects/ : No such file or directory

If I type them manually, it will work, therefore it has to be with my syntax.

Thanks


Solution

  • Thanks I was able to figure it out, just needed to use double quotes, remove the quotes on the path of setfacl and escape the space. Like so:

    plink -load profile1 -batch "setfacl -Rm d:g:user1:rwX,g:user1:rwX /FILES/projects/$Project_number\ $Project_code && find /FILES/projects/$Project_number\ $Project_code -maxdepth 1 -exec setfacl -m d:g:user1:r-X,g:user1:r-X {} \;"