Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Needing help with this script in perl

Status
Not open for further replies.

RikT99

Vendor
Jun 22, 2009
1
I need help with this I am tryinag to get these scripts to make a .torrent file on a complete folder being found on the ftp thats been checked that is complete but cant seem to get them workiing
complete_script.pl file

use strict;
use warnings;
use Cwd;


#my $upname=$ENV{PWD};
#my $upname2=getcwd;
#my $upname3=`pwd`;
#
#my $cout=`btmakemetafile $upname &` . "\n";
#
#`echo $upname > complete_script_has_been_runned`;
#`echo \`ls $upname\` >> complete_script_has_been_runned `;
#`echo $upname2 >> complete_script_has_been_runned`;
#`echo $cout >> complete_script_has_been_runned`;
#`echo $upname3 > complete_script_has_been_runned`;

`echo /glftpd\`pwd\` >> /site/incoming/upload_complete_wait_list.txt `;

watch_for_new_completed.pl file

use strict;
use warnings;

while(1) {
sleep 1;
next unless -f "upload_complete_wait_list.txt";
my $a = `tail -1 upload_complete_wait_list.txt`;
chomp $a;
`btmakemetafile $a &`;
}

do these look right as i cant seem to get it to make the .torrent files
 
It doesn't look right no - I'm ok with Perl but Im having trouble understanding what it's doing -- which part of the script doesn't work? Which part of the script is trying to create a .torrent file? Do you get any error messages at all? You aren't using any error trapping... like this:

do_something || die "error when calling do_something\n$!\n";

Error handling like that can really help.

Mike

 
There are a number of watcher modules on CPAN designed to monitor directories for changes, i.e. an FTP drop-box. As you are using tail I assume you are on *nix. looks like a possible for what you want.

Once you have this part of it working (just get it to print out a message to start with), you can concentrate on the part where you create the torrent files.

Normally in Perl we like to use Perl modules rather than shelling out to other commands like you would in ksh or bash. For example there are modules that support torrents as well.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top