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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple move file mod not working, help newbe here

Status
Not open for further replies.

mishkins

Technical User
Apr 9, 2009
3
CA
why doesn't this work??

it saves but it doesn't move the file

is a snipit of a irc torrent saving script, ... means there was other stuff I just left my additions

entire script isn't posted either but again the important parts...

in subdownload sleep 45 and on is added and speculative

#!/usr/bin/perl
use strict;
use Irssi;
use warnings;
use vars qw(... $temp_dir $watch_dir $newfile...);

$watch_dir = "/home/mishkin/torrent/torrentfiles/";
$temp_dir = "/home/mishkin/torrent/temp/";

sub download {;
my $file = $temp_dir . $sct_release . ".torrent";
$url = "-q --no-check-certificate -O '" . $file . "' '" . $site . "download.php/" . $sct_idm . "/" . $sct_release . ".torrent?passkey=" . $passkey."'";
system("wget $url &" );
sleep 45;
$newfile = $watch_dir . $sct_release . ".torrent";
move("$file","$newfile" );

I kinda followed the example and found the move thing on google but the files arnt being moved to the watch dir
 
perl has no move() function, your code should return an error. The File::Copy module imports a move() function:

use File::Copy;

or you can just use perls rename() function which does pretty much the same thing although File::Copy might be a bit more versatile.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
okay switched to the move copy command

question should I have quotes around my filepaths? they didn't in origonal script

like $newfile = $watch_dir . $sct_release . ".torrent";

should it be


$newfile = "$watch_dir . $sct_release . ".torrent"";
 
Actually its best wriiten without using concatenation, just doub;e-quotes to create the new string:

Code:
$newfile = "$watch_dir$sct_release.torrent";

But to answer your question, the way you were doing it there should be no quotes are the scalar variables. In fact this is wrong for a few reasons:

Code:
$newfile = "$watch_dir . $sct_release . ".torrent"";

You should be using "strict" and "warnings" with your perl code too:

Code:
use strict;
use warnings;





------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top