Page 1 of 1

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 4:51 pm
by gabrielp
Hi guys,

I'm stuck on this annoying issue. I've installed AWS CLI on our production machine but for some reason, even though I can access it fine within Terminal, Switch cannot get any response out of it.



Here is a screenshot showing the result from Switch trying 'aws --version' along with Terminal doing it:





Notice how nothing is in the result for Switch and yet it prints a line in Terminal where the same command is being run.



To prove my scripting example works, here is the same thing with 'curl --version' which works as expected....





Anyone have any idea what is going on here?

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 5:10 pm
by gabrielp
FYI, I have tested this on two machines running Windows 7 and could not reproduce the issue. It seems to be something with OSX.

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 5:12 pm
by dkelly
curl is a binary executable whereas aws is a python script. It's probably a problem with the shell invoking the correct interpreter. Try prefixing aws command with the path to 'python'.

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 5:35 pm
by gabrielp
Good call, Dwight. I was able to get it working like this:







But obviously that's not workable because I want it to work across platforms. So how can I fix the OS X environment to respond correctly to 'aws --version'?

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 5:42 pm
by gabrielp
The first line of this file should be all that's needed...




Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 7:11 pm
by gabrielp
Annoying issue but I've implemented a simple workaround which, when it fails the first time, tries to prepend 'python /usr/local/bin/' to the command, making it work. This means that for OSX, if you encounter the problem, you'll need your AWS installed in /usr/local/bin/. Kind of a bummer but it was the only way I could get it working.

Terminal command not returning stdout like it should

Posted: Fri Jan 23, 2015 7:19 pm
by dkelly
use s.isMac() to determine if you need to add "python" to command