Ashish Karpe Ashish Karpe - 6 months ago 49
Bash Question

Getting "error s3cmd: command not found" while running it from script

Getting "error s3cmd: command not found" while running it from script in spite of installing it & setting environment variable. Also able to run s3cmd from command prompt !

Log :

# tail -f /mnt/log/frengo/s3_sync_ox_data_raw_ad_external_2.log
SECONDS:0 MICRO_SECONDS:299000
SECONDS:0 MICRO_SECONDS:45000
INDEX:2 CURRENTHOUR:11 CURRENTMINUTE:19 CURRENTMINUTEINTERVAL:1
START S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.037471786
/root/adserver_cron/./s3_sync_index.sh: line 92: s3cmd: command not found
END S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.038967376
INDEX:2 CURRENTHOUR:11 CURRENTMINUTE:13 CURRENTMINUTEINTERVAL:0
START S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.292091013
/root/adserver_cron/./s3_sync_prev_index.sh: line 92: s3cmd: command not found
END S3 DOWNLOAD MIN INTERVAL TIME: 11:23:02.293705403


s3cmd :

# /usr/local/bin/s3cmd --version
s3cmd version 1.0.1
# s3cmd --version
s3cmd version 1.0.1


both are same !!

Script :

RESPONSE=$(s3cmd sync s3://dm-raw-files/${INDEX}/${CURRENTDATE}/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ /mnt2/frengo/fileQueue/${INDEX}/s3/${TABLENAME}/${CURRENTHOUR}/${CURRENTMINUTEINTERVAL}/ 2>&1 )


s3cmd is working from command prompt :

# s3cmd ls s3://dm-raw-files
DIR s3://dm-raw-files//
DIR s3://dm-raw-files/0/
DIR s3://dm-raw-files/1/


Has set env variable also :

# cat ~/.bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


if [ -d "$HOME/s3" ]; then
PATH="$HOME/s3:$PATH"
fi

Answer

Change the script to include the full path of s3cmd:

RESPONSE=$(/usr/local/bin/s3cmd sync s3://dm-raw-files/......
Comments