Shell script works when run in terminal but not when run through OS.execute()

I can run xprop but I cannot find a property that changes depending on whether a window is grabbing my cursor. If I run xprop -spy I see no changes when a window grabs or releases the cursor.