You are not logged in.

#1 2010-03-18 23:47:53

mreiland
Member
Registered: 2007-03-06
Posts: 33

2 questions involving ftp and git.

I have some files I'd like to upload via ftp to a remote server automatically.  I've written a script that takes a specific directory and creates a tarball for it, but I'm not sure how to get the ftp utility to log in to the server, push a single file, and then close (without any interaction from me).  I've looked over the man pages and I may be missing something but I'm not seeing it.

My second question.

I have a 1.7 git repo and I'd like to push it to a remote repository.  The remote machine has 1.6 git on it.  I can't really seem to find any information on this specifically, is this something that can reasonably be done?

Offline

#2 2010-03-19 01:43:53

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: 2 questions involving ftp and git.

Create a .netrc in the $HOME of the user who will be doing the uploading. You must, of course, also make sure that your ftp client honours .netrc configuration.

Google for .netrc details - there's plenty available.

Offline

#3 2010-03-19 04:34:15

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: 2 questions involving ftp and git.

I was struggling with this some time ago, and I finally solved it like this. Just modify to your needs.

#!/bin/sh
# mpdftp
# though lftp claims to support wildcards, I never got them to work
# instead I wrote this little script to automagically upload music based on mpc searches
# trapd00r.se

ftphost="dopehost"
username="user"
password="pass"
tempfile=$(mktemp)

echo -e "debug\n open -u $username,$password $ftphost" > $tempfile

if [ $# == 0 ]; then
        echo -e "Usage: $0 [OPTION]... 
        -a\t query artist
        -al\t query album"
fi

if [ "$1" == "-a" ]; then
        files=("$(mpc search artist "$2"|perl -pe 's/(.*\/.*\/).*/$1/')")
elif [ "$1" == "-al" ]; then
        files=("$(mpc search album "$2"|perl -pe 's/(.*\/.*\/).*/$1/')")
fi
for file in "${files[@]}"; do
        echo "$file"|perl -pe 's/^/mirror -R \/mnt\/Music_1\//g' >> $tempfile
done
lftp -f $tempfile

Offline

Board footer

Powered by FluxBB