0

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?

1 Answer 1

2

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}'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.