#!/usr/bin/perl
########################################################################
#
# irpgupd.pl v0.1 - by MEiJ <meij101@hotmail.com>
#
# -----------------------------------------------
# About:
# Uploads your irpg files from one server to another via FTP
#
# Instructions:
# Make sure the file is CHMOD'd at 777, then to test it out (once
# you've configured it) just type './irpgupd.pl' you should be
# alerted to any errors, if none appear the files should have been
# uploaded.
#
# Should you want this to update every x or y mins you should add it
# to crontab. Heres a little example of what to add to make it update
# every 10 mins.
# 0,10,20,30,40,50 * * * * /full/path/to/irpgupd.pl >/dev/null 2>&1
#
# History:
# 0.1
# - Initial release
#
########################################################################
use Net::FTP;
my %opts = (
# Your ftps host or ip address.
host => 'ftp.xxxxx.dk',
# Your ftps port.
port => 21,
# Your ftps username.
username => 'xxxxx',
# Your ftps password.
password => 'xxxxx',
# Max timeout. (in seconds)
timeout => 30,
# Local files to upload, and what to CHMOD them (leave blank if
# you dont need CHMOD). to use the CHMOD function put for
# example ':600' after the filename. (remember to use full paths)
localfiles => ['D:\FTP\Bot.v3.1.0\irpg.db:600',
'D:\FTP\Bot.v3.1.0\modifiers.txt',
'D:\FTP\Bot.v3.1.0\questinfo.txt'],
# The path to the folder you would like to upload the files to
# via ftp.
remotedir => '/'
);
#####################################
# Shouldnt need to edit below here! #
#####################################
$ftp = Net::FTP->new($opts{host}, Timeout => $opts{timeout}) or $error = 1;
miscerror("0", "Couldnt connect to $opts{host}.") if $error;
$ftp->login($opts{username}, $opts{password}) or $error = 1;
miscerror("1","Couldnt login to $opts{host}.") if $error;
foreach(split(/\//, $opts{remotedir})) {
$ftp->cwd($_) or $error = 1 if $_;
miscerror("1","Couldnt change directory to $opts{remotedir} ($_).") if $error;
}
foreach(@{$opts{localfiles}}) {
my ($fullfile, $chmod) = split(/:/);
$filename = $1 if ($fullfile =~ /.*\/(.*?)$/);
if ($filename && -e $fullfile) {
$ftp->put($fullfile, $filename) or print "Warning: Couldnt upload $filename, skipping.\n";
$ftp->site("CHMOD $chmod $filename") or print "Warning: Couldnt CHMOD $filename, skipping.\n" if $chmod;
} else {
print "Warning: $fullfile is either not a file or doesnt exist, skipping.\n";
}
}
$ftp->quit;
sub miscerror {
print "Error: $_[1]\n";
$ftp->quit if ($_[0] > 0);
exit 0;
}
en der kan se fejl i dette script . når det bliver startet popper den op og væk igen uden der sker noget .s