I'm sorry that I can't be extremely specific, I really don't know what is the problem and just started with bash so my debugging skills are limited to echo.
I have the following piece of code:
#! /bin/bash
# post_torrent.sh
{
# Log file, file where we tell what events have been processed.
LOG_FILE=/Users/Server/Documents/sickbeard/logs/post_torrent.log
# Username for transmission remote.
TR_USERNAME="admin"
# Password for transmission remote.
TR_PASSWORD="1234"
# Get current time.
NOW=$(date +%Y-%m-%d\ %H:%M:%S)
# Source directory, should not be changed.
SRC_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}/"
# Directory to store the un-compressed files in..
DEST_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}/"
cd $SRC_DIR
echo $NOW "SRC_DIR $SRC_DIR" >> $LOG_FILE
RAR=$(find . -iname "*.rar")
echo $NOW "RAR $RAR" >> $LOG_FILE
unrar x -inul "$RAR"
exit 0
} &
The log file shows that the correct files are being used. When i execute the statements in the script one by one in the terminal (I am working on a mac osx server) everything works and the file gets extracted. However when this script is executed after a torrent has been downloaded it does not.
I have been trying to find out why this is for about three hours and still have not found any clue. I think the permissions are OK as I tested for that. I am however new to bash and not too familiar with the mac osx command line.
Thanks in advance.
EDIT: some extra information. the log looks like this: 2013-02-27 00:14:42 SRC_DIR /Volumes/Multimedia/aa_bb/Downloads/some_serie/ 2013-02-27 00:14:42 RAR ./some_serie.rar
The program gets executed through transmission as the program set when a file finishes downloading.
The file that has to be extracted is on a shared external hard drive.
Hope this helps.