Page 1 of 1

(Linux) Help with FTP script

Posted: September 25th, 2009, 11:57 pm
by 8th sin
Hello,

Let me begin by saying that SABnzbd is an incredible piece of software! I'm hoping someday soon to use its RSS capability to ditch cable TV altogether.

At any rate, I am currently trying to write a bash script to upload via FTP completed nzb's to my Popcorn Hour (networked media player, if you don't already know). The script runs without error when an NZB is completed, however on my first test run it tried to upload my entire /usr/bin directory!

Just about everything I know about scripting I have learned in the past couple hours, and I am having trouble pinning down what is going on with the directories here. I am assuming $1 will pass in the path to the completed nzb (ie - /home/brian/downloads/complete/NZB_DIR/). Then I use mput to upload everything in that directory to /Video. Here is what I have so far:

Code: Select all

#!/bin/bash

HOST='192.168.1.188'
USER='ftpuser'
PASSWD='1234'

cd $1

ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd Video
mput *
bye
bye
EOT

Re: (Linux) Help with FTP script

Posted: October 7th, 2009, 8:29 pm
by 8th sin
Figured it out... the %1 needed to be in quotes. easy enough.

Here's my final result, with a call to another script at the bottom that refreshes the database on the popcorn hour:

Code: Select all

#!/bin/bash

HOST='192.168.1.188'
USER='ftpuser'
PASSWD='1234'

cd "$1"

ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd Video
mput *
bye
bye
EOT

cd "/home/brian/YAMJ/"
echo "Running YAMJ...."
./MovieJukebox.sh -c /home/brian/nmt/Video -o /home/brian/nmt/Video