Reputation: 996
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
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
Does anybody see anything wrong with this? I am not sure what I doing wrong.
Output of ls -l /usr/bin/env
-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
Partial solution: tr -d '\r' < /users/zmjones/.ec2/bin/ec2-add-keypair > /users/zmjones/.ec2/bin/ec2-add-keypair
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 ~/.ec2
tried ec2-describe-images -o amazon
and got the bad interpreter error. I renamed ec2-describe-images
to ec2-describe-images.bak
ran the tr
command listed above and tried it again. I then receive a permission denied error
. When I run it with sudo it tells me that EC2_HOME
isn't set, but echo $EC2_HOME
indicates that it is. I ran chmod +x ec2-describe-images
and now I am back to the same bad interepreter error.
Upvotes: 1
Views: 7884
Reputation: 3396
This happened to me on Windows because I had the wrong header in my bash files. I had
#!/usr/bin/bash
instead of #!/usr/bin/env bash
which is the portable version.
Upvotes: 2
Reputation: 11
I got the exactly the same problem.
The CAUSE of the problem is the "unarchiver tool".
I've installed a third party unarchiver tool. It might change the line-endings of the files during the unzipping process.
After I realized this, I deleted this tool and re-unziped the EC2 zip ball using the native unzip tool. And the problem was solved.
Hope this might be useful for you guys with the same problem.
Upvotes: 1
Reputation: 141918
/users/zmjones/.ec2/bin/ec2-add-keypair
has DOS line-endings.
To fix:
mv /users/zmjones/.ec2/bin/ec2-add-keypair /users/zmjones/.ec2/bin/ec2-add-keypair.bak
tr -d '\r' < /users/zmjones/.ec2/bin/ec2-add-keypair.bak > /users/zmjones/.ec2/bin/ec2-add-keypair
Upvotes: 2