I am in no way an accomplished script-writer, but this seemed to be in my range.. but alas! I just can't understand what I am doing wrong..
I am trying to read the $TR_TORRENT_DIR variable, and then ftp the downloaded files to my local ftp server, choosing a folder based on the string value.
I have tried several approaches, and the command function part works fine
Code: Select all
#!/bin/bash
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /TV/
lcd $TR_TORRENT_DIR
cd /TV/
put $TR_TORRENT_NAME
bye
EOF
Now.. My If Then else statements does not seem to work, as it will not initiate any transfers when the code looks like this:
Code: Select all
#!/bin/bash
if [[ "$TR_TORRENT_DIR" == *data* ]]
then
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /TV/
lcd $TR_TORRENT_DIR
cd /TV/
put $TR_TORRENT_NAME
bye
EOF
elif [[ "$TR_TORRENT_DIR" == *ptp* ]]
then
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /Movies/
lcd $TR_TORRENT_DIR
cd /Movies/
put $TR_TORRENT_NAME
bye
EOF
elif [[ "$TR_TORRENT_DIR" == *0day* ]]
then
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /0day/
lcd $TR_TORRENT_DIR
cd /0day/
put $TR_TORRENT_NAME
bye
EOF
else
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /Diverse/
lcd $TR_TORRENT_DIR
cd /Diverse/
put $TR_TORRENT_NAME
bye
EOF
fi
Code: Select all
#!/bin/bash
tvserie() {
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /TV/
lcd $TR_TORRENT_DIR
cd /TV/
put $TR_TORRENT_NAME
bye
EOF
}
movies() {
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /Movies/
lcd $TR_TORRENT_DIR
cd /Movies/
put $TR_TORRENT_NAME
bye
EOF
}
0day() {
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /0day/
lcd $TR_TORRENT_DIR
cd /0day/
put $TR_TORRENT_NAME
bye
EOF
}
diverse() {
lftp << EOF
open -u username,password my.ftp.site
mirror -R $TR_TORRENT_DIR/$TR_TORRENT_NAME /Diverse/
lcd $TR_TORRENT_DIR
cd /Diverse/
put $TR_TORRENT_NAME
bye
EOF
}
if [ $TR_TORRENT_DIR = "/my/tv/series/folder/" ]; then
tvserie
elif [ $TR_TORRENT_DIR = "/my/movie/folder/" ]; then
movies
elif [ $TR_TORRENT_DIR = "/my/0day/folder/" ]; then
0day
else
diverse
fi
.dexus.