Created
March 14, 2013 17:54
-
-
Save DavidEGx/5163549 to your computer and use it in GitHub Desktop.
Some tasks i want to run when a amule download is finished
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# ---------------------------------------------------------------------------- | |
# Ejecuta ciertas tareas cuando un fichero se descarga. | |
# Info amule: http://wiki.amule.org/index.php/Events | |
# | |
# Tareas ejecutadas: | |
# - Se crean tantos enlaces duros como carpetas existan en @folders. Al tener | |
# cada usuario una carpeta independiente esto posibilita que un usuario se | |
# descargue un fichero y lo pueda eliminar inmediatamente. | |
# El fichero existira hasta que todos los usuarios lo borren. | |
# | |
# | |
# fxMlOF | |
# ---------------------------------------------------------------------------- | |
use strict; | |
use warnings; | |
use File::Copy; | |
use File::Basename; | |
my $log = "/home/amule/finish.log"; | |
open(my $fh, ">>", $log); | |
print $fh "Ejecuntando para " . $ARGV[0] . "\n"; | |
close($fh); | |
my @folders = qw{ | |
/home/amule/Incoming/A | |
/home/amule/Incoming/D | |
/home/amule/Incoming/L | |
/home/amule/Incoming/R | |
}; | |
my $file = $ARGV[0]; | |
die "El fichero no existe" unless (-f $file); | |
my($filename, $directories, $suffix) = fileparse($file); | |
my $firstFolder = shift(@folders); | |
move($file, $firstFolder); | |
foreach my $folder (@folders) { | |
link("$firstFolder/$filename", "$folder/$filename"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment