[SOLVED]Strange Result

Posted on
Tue Jun 10, 2014 3:41 pm
michaelu offline
Posts: 25
Joined: Feb 01, 2010

[SOLVED]Strange Result

Ok,

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?

Posted on
Tue Jun 10, 2014 5:42 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Strange Result

The problem is one of environment. When you run the script via Sublime or in a shell, it works because it's using the environment set up when you logged in so the PATH is set and the "ping" command is in the path. However, when the IndigoServer process runs, there is no environment set up. Bottom line, you need to specify the full path to the executable you want to execute - in this case, /sbin/ping.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jun 12, 2014 1:26 pm
michaelu offline
Posts: 25
Joined: Feb 01, 2010

Re: [SOLVED]Strange Result

WORKED INSTANTLY!

And of course, makes perfect sense now! Thank you SOOO much for your assistance! All my scripts just SNAPPED into working order!

I've been migrating all my applescripts to Python and these were just a thorn in my side, but NO LONGER!

Thanks again for your WONDERFUL software and WONDERFUL support!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests