Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 1:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.