1

I am trying to setup up Amazon's EC2 service and am having some trouble.

I have downloaded the Amazon EC2 API Tools, which I've put in a folder ~/.ec2 along with my .cert and .pemfiles.

When I attempt any command from ~/.ec2/bin I get an error /Users/zmjones/.ec2/bin/ec2-cmd: /usr/bin/env: bad interpreter: Operation not permitted. I asked about this in "/usr/bin/env bad interpreter".

Now that I have removed the DOS line-endings using variants of this 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, I've tried to execute some of the commands in ~/.ec2/bin and have been unable to get it to work.

I've gotten a permission denied error, which when I then use sudo, tells me that the environment variable EC2_HOME doesn't exist, while echo $EC2_HOME indicates that it does. Here is my ~/.bash_profile.

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=$EC2_HOME/bin:$PATH
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
Community
  • 1
  • 1
Zach
  • 996
  • 12
  • 25

2 Answers2

2

You're getting a "permission denied" error because the execute (+x) bit is not set on your modified script.

Do not use sudo to fix this.

Simply set the +x bit:

chmod +x /users/zmjones/.ec2/bin/ec2-add-keypair

(and the same for your other scripts with fixed line endings).

The reason sudo didn't work is that by default it starts with a clean environment, without your EC2_HOME and other environment variables.

The reason you don't want to use sudo to fix the problem anyway, is that running with sudo runs the whole program as root, which has the possibility of doing bad things on your system. At the very least, it might create files or subdirectories in your local directory that are owned by root, which you then have to take extra steps to modify/delete later. At worst, a bug in the program could wipe out your whole system, or important parts of it.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Yea I've done that, sorry did not mention it. I get the bad interpreter error after I do that. – Zach May 10 '12 at 01:24
  • 1
    You already know how to fix the bad interpreter problem, that means you have *another* script with DOS line endings. Perhaps you could download an EC2 tools package that's appropriate for the OS you're using, so you don't have to manually change the line endings? – Greg Hewgill May 10 '12 at 01:25
  • This is on a file that I have already removed the DOS line endings from. I also have tried manually editing the file, and removing the comments that seem to be generating the eol characters. Same deal. There only seems to be the one set of dev tools for EC2. I haven't found another downloadable set. – Zach May 10 '12 at 01:28
0

If ls -al@ shows com.apple.quarantine extended attrib, the files won't be executed. You'll need

xattr -d com.apple.quarantine filename
doubleDown
  • 8,048
  • 1
  • 32
  • 48
ABakker
  • 1
  • 1