Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Upload .torrent files to your seed server

So let's say over the course of the day you download a lot of .torrent files and you need to upload them to your seebox, this is how I do it, via a crond job. This uploads all the .torrent files in the ~/Downloads directory:

Code
for i in $(find ~/Downloads -newermt "2014-11-07" | grep "torrent$" ); do scp -r $i bsdpunk@seedbox:/home/disk1/bsdpunk/torrents/watch; done
Always more OC on my blog:
BSDPunk's BLog
Nice script OP, you mind explaining what the code exactly does and works?
(Nov 28, 2014 08:39 PM)'Palladium Wrote:  Nice script OP, you mind explaining what the code exactly does and works?

This looks like a shell script that loops through and finds all .torrent files newer than 2014-11-07 that reside in the Downloads in the users home dir. It then uses SCP (secure copy) to transfer the .torrent to the user's seedbox at the specified location.
There's no place like ~/
I'd rather have all my content organized perfectly and then use rsync to pull the data from my machine everyday with cron. Just how I prefer to do it.
Or you can get cron and SSH on a seedbox right ? never used one.
So yeah doing an rsync to get your data with a cron is great. But this is for putting the .torrents in your watch directory that you recently downloaded.
Always more OC on my blog:
BSDPunk's BLog
not a bad setup, you could also work with something like this:

Code
watch_dir=~/Downloads
upload_dir=/home/disk1/bsdpunk/torrents/watch
sleep_duration=10
spin='-\|/'

i=0
while true
do
    saveifs=$IFS
    IFS=$(echo -en "\n\b")
    files=$(ls -a $watch_dir*.{torrent} 2> /dev/null)

    if [ ${#files} -eq 0 ]; then
      i=$(( (i+1) %4 ))
      printf "\r[${spin:$i:1}] %s" `date +%Y-%m-%d:%H:%M:%S`
    fi

    for f in $files
    do
      lsof $f > /dev/null
      if [ $? -eq 1 ]; then
                      echo
      scp -r $f bsdpunk@seedbox:$upload_dir
      else
      sleep_duration=1
      i=$(( (i+1) %4 ))
      printf "\r[${spin:$i:1}] %s is being written" $(basename $f)
      fi
    done
    IFS=$saveifs
done

You just need to run this once and leave it in the background, screen would be ideal for this

SSH Keys also make this automated, which I presume you already setup, but forgot to mention ;)
~Insert Sig~
So I have a similar setup I showed here:
https://hackforums.net/showthread.php?tid=4572034

but yeah it's wicked awesome, and I have ssh keys set up.

But much love @djmodz
Always more OC on my blog:
BSDPunk's BLog


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by severosFeb 10, 2017 11:15 AM 10 564 Feb 10, 2017 11:15 AM
Last Post: severos
[C] by puppetrocksFeb 5, 2016 09:28 PM 7 292 Feb 5, 2016 09:28 PM
Last Post: 0xDEAD10CC
[.NET] by DecimJan 15, 2016 02:09 PM 14 1,439 Jan 15, 2016 02:09 PM
Last Post: Forecraft