I've been working with Python (I have applescript / ruby / unix experience) and have had some great results, I've been using SublimeText 2 in my practice scripts and have been able to accomplish EVERYTHING of what I am trying to do...
HOWEVER
When i put those scripts into Indigo I get different results, here is what I am trying to do:
Run a Unix command from python and based on the result, change a variable. This works in Sublime and parses the result and is prepped to change the variable but when i run this in Indigo, i get numbers (likely error/result codes) that I am not expecting.
Here is one version of my script that is simplified to simply LOG the result of the UNIX command into indigo, in this case PING
- Code: Select all
import subprocess
myMichaelPing = subprocess.call("ping -c 1 -o -t 1 10.0.1.1", shell=True)
indigo.server.log(str(myMichaelPing))
Now, in Submlime when i run that (without the indigo line), i can print the result of the ping command and parse as needed but in Indigo when i write the result to the log as string i only get '127' printed in the log.
I looked up the older way to do this, so I tried this command:
- Code: Select all
import os
myMichaelPing = str(os.system("ping -c 1 -o -t 1 10.0.1.1"))
indigo.server.log(str(myMichaelPing))
Except this time i get '32512' in the log window... But again, in Sublime i get the result of the command and am able to parse the results for my needs...
Any idea why this is not working? I'm not a heavy coder but am just surprised what i see on the forums and what others are able to do but why this specific code isn't doing what i want...
Thoughts?