Using samba I mounted a UNIX folder into windows folder.
Now I am trying to get a perl script that copied files from C:\ to this mounted drive which is called - S:
Following is the script I have so far -
#!/usr/bin/perl -w
use File::Copy;
$TIME_STAMP=`perl -e'@x=localtime time-86400;printf"%4d_%02d
_%02d\n",$
x[5]+1900,
$x[4]+1,$x
[3]'`; # to get yesterday's date
$PATH1 = "\\itkm-kcc1\Knova home\Platform\Log"; # source file1 location
$PATH2 = "\\itkm-kcc2\Knova home\Platform\Log"; # source file2 location
$FILE1 = "general_activity-Producti
on-ITKM-KC
C1-.-$TIME
_STAMP"; # source file 1 name
$FILE2 = "general_activity-Producti
on-ITKM-KC
C2-.-$TIME
_STAMP"; # source file 2 name
#net use s: \\soca01\user; #used to mount the shared drive
opendir(IMD1, $PATH1) || die("Cannot open directory");
if (-e $FILE1)
{
copy($FILE1, S:\$FILE1) || die ("File cannot be copied");
}
closedir(IMD1);
opendir(IMD2, $PATH2) || die("Cannot open directory");
if (-e $FILE2)
{
copy($FILE2, S:\$FILE2) || die("File cannot be copied");
}
closedir(IMD2);
But this script is throwing syntax errors at various steps -
syntax error in file perl_copyfiles at line 3, next 2 tokens "use File"
syntax error in file perl_copyfiles at line 16, next 2 tokens "copy("
Spurious backslash ignored at perl_copyfiles line 16.
syntax error in file perl_copyfiles at line 23, next 2 tokens "copy("
Spurious backslash ignored at perl_copyfiles line 23.
Execution of perl_copyfiles aborted due to compilation errors.
I am new to perl scripting and having hard time trying to debug this.
Also please let me know how to automate this script using cron.
Your help is appreciated.
Thanks
Start Free Trial