I am trying to launch an app on elastic beanstalk in the php 5.5 container. there are 3 environments dev, staging and production. You cannot distinguish between environments when setting environment variables from the command line so I am using a workaround suggested by aws support which is to run a shell script on deployment to set the variables depending on the existence of another variable I can vary depending on environment

.When i deploy my app there is a config file in .ebextensions/ like so

```
container_commands:
  command01:
    command: "./.ebextensions/setEnvVars.sh"

```

the shell script is also in .ebextensions and it looks like so

```
#!/bin/bash
case "$PARAM1" in
        "development")
                echo -e "SetEnv APP_ENV development\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
        "production")
                echo -e "SetEnv APP_ENV production\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
        "staging")
                echo -e "SetEnv APP_ENV staging\n
                         SetEnv DB_HOST *******\n
                         SetEnv DB_NAME *******\n
                         SetEnv DB_USERNAME *******\n
                         SetEnv DB_PASSWORD *******\n" > .htaccess
                ;;
esac

if [ -f .htaccess ]; then
        chmod 644 .htaccess
fi

```

when the app deploys I get this error

```
[Instance: i-400fc60f Module: AWSEBAutoScalingGroup ConfigSet: null] Command failed on instance. Return code: 1 Output: Error occurred during build: Command command01 failed .

```

and this is what I think is the relevant ecert from the logs

```
2014-02-03 12:54:25,531 [INFO] (1923 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build: Command command01 failed
, stderr: None)
2014-02-03 12:54:25,533 [DEBUG] (1923 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_sets': ['Infra-WriteRuntimeConfig', 'Infra-WriteApplication1', 'Infra-WriteApplication2', 'Infra-EmbeddedPreBuild', 'Hook-PreAppDeploy', 'Infra-EmbeddedPostBuild', 'Hook-EnactAppDeploy', 'Hook-PostAppDeploy'], 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: Command command01 failed\n'}], 'api_version': '1.0'}

```

I don't have any experience with elastic beanstalk or shell so there could easily be a syntax error but I honestly dont know were to look