http://qs1969.pair.com?node_id=1177251

flieckster has asked for the wisdom of the Perl Monks concerning the following question:

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"; }

Replies are listed 'Best First'.
Re: no feedback when running a script? (cmd date)
by tye (Sage) on Dec 05, 2016 at 18:52 UTC
    my $current = `date +%m/%d/%Y`­;

    You should try running that command from your Windows cmd prompt:

    C:\>date +%m/%d/%Y The system cannot accept the date entered. Enter the new date: (yy-mm-dd) C:\>

    So that (it wanting you to enter the new date you want used) could be the problem.

    - tye        

      that seems to have done it. I guess that date was asking for new date but not displaying in the CMD line. thank you!

        You might want to correct this line also
        chdir( $PSD ) or warn "Cant chanage to $JPG $!";

        poj
Re: no feedback when running a script? (-d)
by tye (Sage) on Dec 05, 2016 at 19:00 UTC
    i even tried running the script right from the cmd line using perl -d C:path to .pl file. i just get this...
    C:\Windows\System32>perl -d Z:\Perl\Mother\Wilsons\Upload\Wilsonsuploa +d.pl ... IO::Socket::SSL::CODE(0x3464058)(C:/Perl64/lib/IO/Socket/SSL.pm:215): 215: INIT { init() } DB<1>

    What did you expect? The debugger does not just find the bug for you automatically. You actually have to tell the debugger what you want done next. Try entering the debugger command "n"?

    - tye        

Re: no feedback when running a script?
by glasswalk3r (Friar) on Dec 05, 2016 at 20:08 UTC

    Since nobody touched these topics, I'll provide some more feedback on your post too:

    • Use the tags readmore to wrap around your code... that will help us to quickly read your post and check all code lines if really necessary. That will only help you to improve your changes to get some help.
    • Don't use backtips only because you can: you probably can do the same things you need with the Datetime Perl module and much more. There are even "lighter" versions of it on CPAN if you're worried about performance. You will have more control of your code and avoid an unnecessary system call.
    Alceu Rodrigues de Freitas Junior
    ---------------------------------
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill