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

File::Copy problem 1

Status
Not open for further replies.

nfaber

Technical User
Oct 22, 2001
446
US
I have a simple script that simply copies a file from one location on a Win2K system to another location on the same server. My problem is in the "" in the copy command. I need to rename to copied file to a name which contains a variable and I am getting multiple errors. Here is my code:

Code:
use File::Copy;

my $logpath = "D:\\file_share\\ov_share";
my $ftppath = "D:\\ovmon";
my $hostname = "n2vftp004";
my @logarr = ("templrep.log","time_log");

foreach  (@logarr) {
	copy ("$logpath\\$_",("$ftppath\\"monout_".$hostname.".txt"));
}
exit(0);

I am not sure where to put the "".


Here are the errors:

Code:
Bareword found where operator expected at D:\File_Share\OV_Share\Perl Scripts\pg
plog.pl line 18, near ""$ftppath\\"monout_"
        (Missing operator before monout_?)
String found where operator expected at D:\File_Share\OV_Share\Perl Scripts\pgpl
og.pl line 18, near "monout_".$hostname.""
String found where operator expected at D:\File_Share\OV_Share\Perl Scripts\pgpl
og.pl line 18, at end of line
        (Missing semicolon on previous line?)
syntax error at D:\File_Share\OV_Share\Perl Scripts\pgplog.pl line 18, near ""$f
tppath\\"monout_"
Can't find string terminator '"' anywhere before EOF at D:\File_Share\OV_Share\P
erl Scripts\pgplog.pl line 18.

Any help is appriciated.
 
use File::Copy;
my $logpath = "D:\\file_share\\ov_share";
my $ftppath = "D:\\ovmon";
my $hostname = "n2vftp004";
my @logarr = ("templrep.log","time_log");
foreach  (@logarr) {
    copy [red]("$logpath\\$_",("${ftppath}\\monout_${hostname}.txt"));
}[/red]
exit(0);


Kind Regards
Duncan
 
Thanks for the basically instant reply. That did the trick!
 
no problem - you are welcome!

thanks for the star :)


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top