Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在脚本中调用exec powershell.exe时使用Ruby变量_Ruby_Powershell - Fatal编程技术网

在脚本中调用exec powershell.exe时使用Ruby变量

在脚本中调用exec powershell.exe时使用Ruby变量,ruby,powershell,Ruby,Powershell,编写一些ruby代码,其中一些将使用exec Powershell.exe命令进行Powershell调用 如何使用现有的Ruby变量并将其传递给Powershell命令 代码: 那不行。如何在powershell调用中使用mydata Ruby变量 要在字符串中插入值,需要使用双引号 exec "Powershell.exe write-host #{mydata}" 而不是 exec 'Powershell.exe write-host #{mydata}' exec 'Powershe

编写一些ruby代码,其中一些将使用exec Powershell.exe命令进行Powershell调用

如何使用现有的Ruby变量并将其传递给Powershell命令

代码:


那不行。如何在powershell调用中使用mydata Ruby变量

要在字符串中插入值,需要使用双引号

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

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