Here's something written in perl that could work. If you don't like perl it may at least give you an idea of what to do in your own script. I tried to write it readable.
Start the script with this call svn status | perl scriptname.pl
.
The script reads the output of svn status line by line. It checks if the lines describe an added, modified/replaced or deleted element and adds the path of the element to the corresponding list. Then it tries to connect to the FTP server and changes the elements there.
The FTP part is completely untested.
I haven't tested what SVN does when you add a folder with subelements in it. Maybe you have to add all the subelements to @filesAdded
by yourself.
#!/usr/bin/perl
use Net::FTP;
use strict;
use warnings;
my $username = "username";
my $password = "password";
my $host = "example.com";
my $port = 20;
my $path = "/some/path/";
my @filesAdded;
my @filesModified;
my @filesDeleted;
while(<STDIN>) {
chomp;
if (/[A]...... (.+)/) {
push @filesAdded, $1;
} elsif(/[MR]...... (.+)/) {
push @filesModified, $1;
} elsif (/[D]...... (.+)/) {
push @filesDeleted, $1;
}
}
print "========================[ CHANGES ]========================\n";
print "filesAdded[".(scalar @filesModified)."]=".(join ", ", @filesModified)."\n";
print "filesModified[".(scalar @filesModified)."]=".(join ", ", @filesModified)."\n";
print "filesDeleted[".(scalar @filesDeleted)."]=".(join ", ", @filesDeleted)."\n";
print "==========================[ FTP ]==========================\n";
{
my $ftp = Net::FTP->new(Host => $host, Port => $port) or die "Cannot connect to $host: $@";
$ftp->login($username, $password) or die "Cannot login ", $ftp->message;
$ftp->cwd($path) or die "Cannot change working directory ", $ftp->message;
for my $fileAdded (@filesAdded) {
if(-f $fileAdded) {
$ftp->put($fileAdded);
} elsif(-d $fileAdded) {
$ftp->mkdir($fileAdded, 1);
}
}
for my $fileModified (@filesModified) {
$ftp->put($fileModified, $fileModified);
}
for my $fileDeleted (@filesDeleted) {
if(-f $fileDeleted) {
$ftp->delete($fileDeleted);
} elsif(-d $fileDeleted) {
$ftp->rmdir($fileDeleted, 1);
}
}
$ftp->quit;
}
print "========================[ SUCCESS ]========================\n";