hello, i recently move from mac scripting to PC world. for the most part things are ok. I ran into one script where i can't seem to see whats wrong with it. when its open in padre it shows no syntax errors and when i modify the directory to that of my mac this script works fine. When I run it on my PC it just seems to sit there doing nothing.
i even tried running the script right from the cmd line using perl -d C:path to .pl file.
i just get this...
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\System32>perl -d Z:\Perl\Mother\Wilsons\Upload\Wilsonsuploa
+d.pl
Loading DB routines from perl5db.pl version 1.49_04
Editor support available.
Enter h or 'h h' for help, or 'perldoc perldebug' for more help.
IO::Socket::SSL::CODE(0x3464058)(C:/Perl64/lib/IO/Socket/SSL.pm:215):
215: INIT { init() }
DB<1>
here's my script.
#!/usr/bin/perl -w
use Net::FTP;
use File::Copy;
use Net::SMTP;
use File::Basename;
use Email::Send::SMTP::Gmail;
use POSIX qw(strftime);
my $date = strftime("%m-%d-%y",localtime);
my $time = strftime("%I:%M:%S",localtime);
my $ftpdate = strftime("%m-%d-%y",localtime);
#PC
my $logfile = "/Users/bflieck/Documents/Wilsons_push.txt";
#mac
# my $logfile = "/Users/flieckb/Documents/Wilsons_push.txt";
my $log = ">> $logfile";
#"//10.55.11.15/
###############define all the folders in this game##############
my $PSD = "//10.55.11.15/photorepos/Partners/Wilsons/Done/";
my $JPG = "//10.55.11.15/photorepos/Partners/Wilsons/2push/";
my $repos = "//10.55.11.15/photorepos/Weekly_Product_Folders/Wilsons/"
+;
my $reposdate = "//10.55.11.15/photorepos/Weekly_Product_Folders/Wilso
+ns/$date/";
my $repospsddate = "//10.55.11.15/photorepos/Weekly_Product_Folders/Wi
+lsons/$date/PSD/";
my $repostiffdate = "//10.55.11.15/photorepos/Weekly_Product_Folders/W
+ilsons/$date/JPEG/";
my $mybadmatch="_s.jpg";
my $badswatches= "//10.55.11.15/photorepos/Perl/Mother/Wilsons/badswat
+ches/";
################################################################
my $current = `date +%m/%d/%Y`;
chomp $current;
chomp $date;
#############Sort the JPG's for bad swatch files
chdir( $JPG ) or warn "Cant chanage to $JPG $!";
(@upload_JPG) = glob "*";
my $upload_count_JPG = @upload_JPG;
foreach my $file (@upload_JPG) {
if ($file =~ m/$mybadmatch/is)
{
my $old = "$JPG$file";
my $new = "$badswatches";
move ($old, $new) or warn print "can't copy the badswatches $file\n";
open FILE, '>> //10.55.11.15/photorepos/Perl/Mother/Wilsons/Upload/Rem
+ovedSwatches.txt' or warn $!;
print FILE "$current\t$date\t$file\t";
print FILE "\n";
}
else
{
print "these dont have to move $file\n";
}
}
close FILE;
#get the PSD folder count
chdir( $PSD ) or warn "Cant chanage to $JPG $!";
(@PSD) = glob "*";
my $PSD_count = @PSD;
###########################################
chdir( $JPG ) or warn "Cant chdir to $JPG $!";
my(@file_list) = glob "*";
open FILE, "$log" or warn $!;
foreach my $file (@file_list){
my $filenameonly;
my $style;
my $color;
my $view;
if ($file =~qr/\A([^_]+)_([^_]+)(?:_([^_]+))?\.([^\.]+)\z/
) {
$filenameonly = $1 .'_'. $2;
$style = $1;
$color = $2;
$view = $3;
} else {
#File did not match...
next;
}
$view = '' if (!defined($view));
print FILE "$current\t$file\t$filenameonly\t$style\t$color\t$view\tWil
+sons\n";
}
close FILE;
#PC
my $dir ="/Users/bflieck/Documents/";
#Mac
# my $dir ="/Users/flieckb/Documents/";
chdir ($dir);
my $filetobecopied = "Wilsons_push.txt";
my $newfile = "//10.55.11.15/photorepos/Reports/Wilsons/Wilsons_push.t
+xt";
if (copy($filetobecopied, $newfile) == 0){;
print"$date $time log error\n";
}
else
{
print "$date $time log updated\n";
}
##########################################
if (@upload_JPG > 0) {
$ftp = Net::FTP->new('******', Debug => 1);
$ftp->login('*****,'*****');
$ftp-> binary();
$ftp->cwd("GSI Images/");
chdir("GSI Images/");
if (-d "ftpdate/"){
$ftp->cwd("ftpdate/");
chdir("ftpdate/");
}
else
{
$ftp->mkdir($ftpdate, 0777);
$ftp->cwd("$ftpdate/");
chdir("$ftpdate/");
}
chdir($JPG);
foreach my $file (glob('*'))
{
$ftp->put($file) or warn $ftp->message;
sleep(0);
}
# ################################################################
chdir($repos) or warn "i cant get to repos $!";
if (-d "$reposdate") {
chdir("$reposdate")
}
else
{
mkdir($date, 0777);
chdir ($reposdate);
}
chdir($reposdate) or warn "i cant get to reposdate $!";
if (-d "$repospsddate") {
chdir("$repospsddate")
}
else
{
mkdir("PSD", 0777);
chdir ($repospsddate);
}
chdir($reposdate) or warn "i cant get to reposdate $!";
if (-d "$repostiffdate") {
chdir("$repostiffdate")
}
else
{
mkdir("JPEG", 0777);
chdir ($repostiffdate);
}
foreach $file (@PSD) {
my $old = "$PSD$file";
my $new = "$repospsddate";
move($old, $new) or warn print "Copy PSD's Failed: $!";}
foreach $file (@upload_JPG) {
my $old = "$JPG$file";
my $new = "$repostiffdate";
move($old, $new) or warn print "Copy JPEG's Failed: $!";}
################################################################
################################################################
my $subject1 = "Industrial Color Studio -- PC Wilsons Image Upload $t
+ime";
my $dllist='wilsonsimages@industrialcolor.com';
my $body ="Hello, below is a list of files that uploaded tonight.<br>T
+here are $upload_count_JPG files pushing tonight\n\n";
my $spacer ="<br>";
my $bodylist =join "<br>\n", @upload_JPG;
my ($mail,$error)=Email::Send::SMTP::Gmail->new( -smtp=>'smtp.gmail.co
+m',
-login=>'kopautomatio
+n1@industrialcolor.com',
-pass=>'*****',
-port=> '25',
-debug=> 1,
-timeout=> 1000);
$mail->send(-to=>"$dllist", -from=>"$dllist", -subject=>"$subject1", -
+body=>"$body $spacer $bodylist", -contenttype=>"text/html");
$mail->bye;
$ftp->close();
}
else
{
print "noimages to push tonight";
}