Sunday, March 14, 2010

Uploading files to my Popcorn Hour

I was for some time using SCP to transfer files from my Mac to my Popcorn Hour media player until I discovered Curl. Curl or rather cURL is a utility for transferring files using various internet protocols using URL syntax.

For a one off transfer you can simply use

curl -T {file} -u {user}:{password} ftp://{ip address}{path}

For sending a complete folder I manage to find a useful script (batch_folder_upload.sh) and adapt it for my needs

#!/bin/sh 

Pwd=$(pwd)
fullDir=$Pwd/$1

echo $fullDir

if [ ! -d $fullDir ]
then
   echo "Could not find folder to upload from $fullDir"
   exit -1
fi

for file in $1/* ; do
 echo "Uploading $file to /Upload/$1"
 curl --globoff --ftp-create-dirs -T $file -u ftpuser:1234 ftp://192.168.1.9/Upload/$1/
done

I have included the --globoff argument as curl does not like the use of [ or ] in the filename. Apparantly there is a fix coming for this issue.

Simply invoke the script

   $ ./batch_upload

1 comment:

  1. This article is really fascinating subsequent to there's such a large number of helpful information inside. Express gratitude toward you.We require more information like this regularly. Trust you'll consistently upgrade this web in the future.We require more information like this once a day. Trust you'll frequently overhaul this web in the future.This article is really intriguing subsequent to there's such a large number of valuable information inside. Much obliged to you.

    Clipping Magic

    ReplyDelete