-1

I'm creating a bash script of which will run on a cron, it's purpose is to backup a directory to Amazon S3 using the s3cmd command.

I get the following error when I run the script:

/usr/bin/env: python: Not a directory

When I comment out the s3cmd command the Python error disappears. When I run this command in the terminal it operates as usual.

For those wondering, here's my entire bash script:

#!/bin/bash

# clutching at straws here
# export PATH=/usr/bin/python:$PATH

# get the start time
START_TIME=$SECONDS

# set the log file output
NOW=$(date +"%m-%d-%Y")
FILE="domain_s3_$NOW.log"
PATH="/var/www/domain/log.domain.co/$FILE"
URL="http://log.domain.co/$FILE"

# fire the s3cmd sync command
/usr/local/bin/s3cmd/s3cmd sync --exclude-from /root/.s3cmd-exclude /var/www/ s3://domain-backup-latest/ > $PATH

ELAPSED_TIME=$(($SECONDS - $START_TIME))

# output diagnostic information
echo "Backup information:"
echo "- Duration: $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec"
echo "- Log: $URL"

Edit

I noticed in this related question that the Python script has a different declaration at the top of the file, I guess I need something like this but I'm only really familiar with bash scripting at this stage.

Ben Everard
  • 599
  • 3
  • 7
  • 22

1 Answers1

0

Got it, I was setting the $PATH variable, should have known this was too generic, part of the s3cmd script (or dependancies) must be using that.

Lesson learnt.

Ben Everard
  • 599
  • 3
  • 7
  • 22
  • You set the `PATH` variable to include the name of the executable. It should be the name of the directory which contains the executable. That's why you're getting "python: not a directory". – Dennis Williamson Apr 30 '14 at 01:48