title: /usr/bin/env bad interpreter
body: <p>Trying to get Amazon's EC2 command line tools to work. This is what my .bash_profile looks like. I get the error: /users/zmjones/.ec2/bin/ec2-add-keypair: /usr/bin/env: bad interpreter: Operation not permitted</p>
  
  <pre><code>PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:$PATH
  PATH=/opt/local/sbin:/usr/local/bin:/usr/x11/bin:/usr/texbin:$PATH
  PATH=/usr/local/texlive/2011/bin/x86_64-darwin:$PATH
  PATH=/Library/Frameworks/EPD64.framework/Versions/Current/bin:$PATH
  EC2_HOME=~/.ec2
  PATH=$PATH:$EC2_HOME/bin
  EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
  EC2_CERT=`ls $EC2_HOME/cert-*.pem`
  JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
  
  export PATH
  </code></pre>
  
  <p>Does anybody see anything wrong with this? I am not sure what I doing wrong. </p>
  
  <p>Output of <code>ls -l /usr/bin/env</code></p>
  
  <pre><code>-r-xr-xr-x  1 root  wheel  34720 Sep  8  2011 /usr/bin/env
  zmjones-mbp:.ec2 zmjones$ /usr/bin/env
  TERM_PROGRAM=iTerm.app
  TERM=xterm
  SHELL=/bin/bash
  TMPDIR=/var/folders/x3/vrw5029d1rj9xblj8bmxl0m00000gn/T/ 
  Apple_PubSub_Socket_Render=/tmp/launch-91y0bp/Render
  OLDPWD=/Users/zmjones
  USER=zmjones
  COMMAND_MODE=unix2003
  SSH_AUTH_SOCK=/tmp/launch-H3JJsl/Listeners
  __CF_USER_TEXT_ENCODING=0x1F5:0:0
  Apple_Ubiquity_Message=/tmp/launch-n2bT2X/Apple_Ubiquity_Message
  PATH=/users/zmjones/.ec2/bin:/Library/Frameworks/EPD64.framework/Versions/Current/bin:/usr/local/texlive/2011/bin/x86_64-darwin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/x11/bin:/usr/texbn
  PWD=/Users/zmjones/.ec2
   JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
  LANG=en_US.UTF-8
  ITERM_PROFILE=Default
  SHLVL=1
  HOME=/Users/zmjones
  ITERM_SESSION_ID=w0t0p0
  LOGNAME=zmjones
  EC2_PRIVATE_KEY=pk-mykey.pem
  DISPLAY=/tmp/launch-6kkP5t/org.x:0
  EC2_CERT=cert-mycert.pem
   _=/usr/bin/env
  </code></pre>
  
  <p>Partial solution: <code>tr -d '\r' &lt; /users/zmjones/.ec2/bin/ec2-add-keypair &gt; /users/zmjones/.ec2/bin/ec2-add-keypair</code></p>
  
  <p>This seems to allow the commands to execute, but they now don't work. For example, I downloaded a new copy of the ec2 api tools, put them in <code>~/.ec2</code> tried <code>ec2-describe-images -o amazon</code> and got the bad interpreter error. I renamed <code>ec2-describe-images</code> to <code>ec2-describe-images.bak</code> ran the <code>tr</code> command listed above and tried it again. I then receive a <code>permission denied error</code>. When I run it with sudo it tells me that <code>EC2_HOME</code> isn't set, but <code>echo $EC2_HOME</code> indicates that it is. I ran <code>chmod +x ec2-describe-images</code> and now I am back to the same bad interepreter error. </p>