簡體   English   中英

在腳本中調用exec powershell.exe時使用Ruby變量

[英]Use Ruby variable when calling exec powershell.exe in script

編寫一些ruby代碼,其中一些將使用exec powershell.exe命令進行Powershell調用。

如何使用現有的Ruby變量,並傳遞到PowerShell命令?

碼:

mydata = 12345
exec 'Powershell.exe write-host #{mydata}'

那不行 如何在Powershell調用中使用mydata Ruby變量?

為了在字符串中插值,您需要使用雙引號。

exec "Powershell.exe write-host #{mydata}"

代替

exec 'Powershell.exe write-host #{mydata}'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM