Reputation: 107
Writing some ruby code, some of which will be making Powershell calls using the exec powershell.exe command.
How do I use an existing Ruby variable and pass it to the Powershell command?
Code:
mydata = 12345
exec 'Powershell.exe write-host #{mydata}'
That doesn't work. How do I use the mydata Ruby variable in the powershell call?
Upvotes: 0
Views: 863
Reputation: 176342
In order to interpolate a value in a string, you need to use double quote.
exec "Powershell.exe write-host #{mydata}"
instead of
exec 'Powershell.exe write-host #{mydata}'
Upvotes: 2