2012-03-21 21 views
0

RubyからPowershellコマンドを実行して結果を取得し、他の処理を実行しようとしています。Rubyから実行中のPowershellコマンドと外部Powershellコマンド

var = `powershell Invoke-Command -computername myserver {Get-Eventlog application -newest 200 |  where {$_.Message -match "Found 0 files to refresh"}}` 
puts var 

$ _が変数iは、以下の取得を行うPSとRubyの間で共有されているので:

INFO:与えられたパターン(S)用のファイルが見つかりませんでした。

このタスクを達成する方法に関するアイデア。

答えて

0

$_.MessageはRubyのグローバル変数ですか?

var = `powershell Invoke-Command -computername myserver {Get-Eventlog application -newest 200 |  where {#{$_.Message} -match "Found 0 files to refresh"}}` 
+0

いいえ、$ _。メッセージはPowershell変数ですが、rubyはファイルハンドルだと思っています:S – Maverick

関連する問題