VMware {code} Community
fixitchris
Hot Shot
Hot Shot

VProbes in PowerShell

I am running into the same issue with PS that I ran into with CMD. Any ideas?

vprobeLoad: error: EOF while looking for ')'
vprobeLoad: 0 warnings, 1 errors*
Error: Unknown error

$execBinary = new-object System.String "C:\Program Files\VMware\VMware Server\vmrun.exe"
$connectParams = new-object System.String "-T server -h https://localhost:8333/sdk -u user -p pass "
$commandParam = new-object System.String "vprobeLoad "
$vmxParam = new-object System.String '"[standard] store\Windows Server 2003 Standard Edition.vmx" '
$vpParam = @"
'(vprobe VMM1Hz (printf "hello "))'
"@

$startinfo = new-object System.Diagnostics.ProcessStartInfo
$startinfo.FileName = $execBinary
$startinfo.Arguments = $connectParams + $commandParam + $vmxParam + $vpParam
$startinfo.UseShellExecute = $false
$startinfo.RedirectStandardOutput = $true 
$process = [http://System.Diagnostics.Process|http://System.Diagnostics.Process]::Start($startinfo)
$process.WaitForExit()
$process.StandardOutput.ReadToEnd()  

vmrun vprobeLoad my.vmx '(vprobe VMM1Hz (printf "hello!\n"))'

The cmd command tool on Windows permits nesting of like‐type quotes only, either single or double quotes

but not both, so the above vmrun command produces the error message “unknown ident windows” and fails.

You probably want to install Cygwin so you can run VP scripts in a standard bash shell.

0 Kudos
8 Replies
admin
Immortal
Immortal

> $startinfo = new-object System.Diagnostics.ProcessStartInfo
> $startinfo.FileName = $execBinary
> $startinfo.Arguments = $connectParams + $commandParam + $vmxParam + $vpParam
> $startinfo.UseShellExecute = $false
> $startinfo.RedirectStandardOutput = $true 
> $process = [http://System.Diagnostics.Process|http://System.Diagnostics.Process]::Start($startinfo)
> $process.WaitForExit()
> $process.StandardOutput.ReadToEnd()  
> 

I'm not sure based on that, but this style of running vmrun seems a bit over the top. You can run it directly like you would from a command prompt. Is there a reason you didn't do that? I assume it's because of the path. Still you could run it sort of like this:

$vmrun = Get-Command "C:\Program Files\VMware\VMware Server\vmrun.exe"
. $vmrun $arg1 $arg2 $arg3

And this might be a bit easier to diagnose.

0 Kudos
fixitchris
Hot Shot
Hot Shot

The reason was because loading a Vprobe with double quotes did not work from the command line. I thought that maybe .NET Framework would handle it a little differently.

0 Kudos
fixitchris
Hot Shot
Hot Shot

Anybody want to tackle this one with me? I still have to make sure I can pass probes using Posh.

0 Kudos
fixitchris
Hot Shot
Hot Shot

I also tried this in CMD:

set probe1 = "'(vprobe VMM1Hz (printf "hello "))'"
vmrun ... %probe1%

but failed with this error:

vprobeLoad: error: illegal variable reference in top-level context
vprobeLoad: 0 warnings, 1 errors
Error: Unknown error

0 Kudos
fixitchris
Hot Shot
Hot Shot

This, however, does seem to work from CMD:

vmrun ... "(vprobe VMM1Hz (printf \"hello\n\" ))"

This, does not:

vmrun ... "'(vprobe VMM1Hz (printf \"hello\n\" ))'"

0 Kudos
fixitchris
Hot Shot
Hot Shot

This works:

vmrun ... (printf \"%d\t%d\n\" RAX RSP))"

This, does not:

vmrun ... (printf \"%d %d\n\" RAX RSP))"

0 Kudos
fixitchris
Hot Shot
Hot Shot

This probe loads, but does not produce output to vprobe.out:

"(definteger sptr);(vprobe VMM1Hz ( printf    \"%d\t%d\t%d\n\"  sptr   (+ sptr  8 )   (+ sptr  8 ) ))"

0 Kudos
fixitchris
Hot Shot
Hot Shot

Same with this one, it loads, but no output:

"(defaggr agr 0 0);(vprobe VMM1Hz ( do  ( setint str    (sprintf \"%s:%d\"  \"barf\"  12 ))( aggr  agr () () 3)))"

Which is understandable since it is sprintf.

0 Kudos