Hello Monks, I have a pl script that is normally run from a window machine and hits against an smb path. Well the box is going away so I am trying to port the script to a Linux friendly format but I am failing. Can someone please give some advice?

Here is the original script

#!/usr/bin/perl # # PlayBuild-Check.pl v1.0.0 # # Reads PlayBuild.txt and PlayBuildXMAC in the desired folder and look +s for .AHV data. # Outputs logs of builds that can be removed from text files. # my $c_streamingBuildData = "\\\\streaming.myco.net\\streaming\\builds" +; my $c_streamingPlayBuildData = "\\\\streaming.myco.net\\streaming\\Pla +yBuildData"; use strict; use warnings; my @validLangs = ( #"base", "enUS", ); #--------------------------------------------------------------------- +---------- # Parse through PlayBuild.TXT's and output results #--------------------------------------------------------------------- +---------- sub ParsePlayBuildTxt { open NEWPLAYBUILDFILE, ">", "$c_streamingPlayBuildData\\PlayBuild. +txt.good"; open PLAYBUILDLOGFILE, ">", "$c_streamingPlayBuildData\\PlayBuild. +txt.check"; open FILE, "<", "$c_streamingPlayBuildData\\PlayBuild.txt" or die +"Failed to open PlayBuild.txt"; my %buildhash; while (my $line = <FILE>) { my $success = 0; my ($build) = $line =~ s/\n//; if (!-f "$c_streamingBuildData\\${line}\\PlayBuild_IX86.AHV") { print ("${line}: PlayBuild_IX86.AHV does not exist\n"); print PLAYBUILDLOGFILE ("${line}: PlayBuild_IX86.AHV does +not exist\n"); $success = 0; } else { $success = 1; } if ($success eq 1) { # Only add unique directories to the list if (!exists $buildhash{lc("${line}")}) { $buildhash{lc(${line})} = 1; print NEWPLAYBUILDFILE ("${line}\n"); print PLAYBUILDLOGFILE ("${line}: Pass\n"); } else { print PLAYBUILDLOGFILE ("${line}: Duplicate\n"); } } } close PLAYBUILDLOGFILE; close NEWPLAYBUILDFILE; } sub ParsePlayBuildXMACTxt { open NEWPLAYBUILDFILE, ">", "$c_streamingPlayBuildData\\PlayBuildX +MAC.txt.good"; open PLAYBUILDLOGFILE, ">", "$c_streamingPlayBuildData\\PlayBuildX +MAC.txt.check"; my %buildhash; open FILE, "<", "$c_streamingPlayBuildData\\PlayBuildXMAC.txt" or +die "Failed to open PlayBuildXMAC.txt"; while (my $line = <FILE>) { my ($build) = $line =~ s/\n//; if (!-f "$c_streamingBuildData\\${line}\\PlayBuild_XMAC.AHV") { print ("${line}: PlayBuild_XMAC.AHV does not exist\n"); print PLAYBUILDLOGFILE ("${line}: PlayBuild_XMAC.AHV does +not exist\n"); } else { # Only add unique directories to the list if (!exists $buildhash{lc("${line}")}) { $buildhash{lc(${line})} = 1; print NEWPLAYBUILDFILE ("${line}\n"); print PLAYBUILDLOGFILE ("${line}: Pass\n"); } else { print PLAYBUILDLOGFILE ("${line}: Duplicate\n"); } } } close FILE; close PLAYBUILDLOGFILE; close NEWPLAYBUILDFILE; } sub renameTxtFiles { unlink "$c_streamingPlayBuildData\\PlayBuild.txt"; rename "$c_streamingPlayBuildData\\PlayBuild.txt.good", "$c_stream +ingPlayBuildData\\PlayBuild.txt"; unlink "$c_streamingPlayBuildData\\PlayBuildXMAC.txt"; rename "$c_streamingPlayBuildData\\PlayBuildXMAC.txt.good", "$c_st +reamingPlayBuildData\\PlayBuildXMAC.txt"; } #--------------------------------------------------------------------- +---------- # Main entry function #--------------------------------------------------------------------- +---------- sub Main { ParsePlayBuildTxt(); ParsePlayBuildXMACTxt(); renameTxtFiles(); } Main();

Here is what I have done to try and make the script more linux friendly. I really don't know why it's not cooperating, maybe i have just been looking at it for too long. Thanks in advance for the advice.

#!/usr/bin/perl # # PlayBuild-Check.pl v1.0.0 # # Reads PlayBuild.txt and PlayBuildXMAC in the desired folder and look +s for .AHV data. # Outputs logs of builds that can be removed from text files. # my $c_streamingBuildData = "/u01/www/streaming/builds"; my $c_streamingPlayBuildData = "/u01/www/streaming/PlayBuildData"; use strict; use warnings; my @validLangs = ( #"base", "enUS", ); #--------------------------------------------------------------------- +---------- # Parse through PlayBuild.TXT's and output results #--------------------------------------------------------------------- +---------- sub ParsePlayBuildTxt { open NEWPLAYBUILDFILE, ">", "$c_streamingPlayBuildData/PlayBuild.t +xt.good"; open PLAYBUILDLOGFILE, ">", "$c_streamingPlayBuildData/PlayBuild.t +xt.check"; open FILE, "<", "$c_streamingPlayBuildData/PlayBuild.txt" or die " +Failed to open PlayBuild.txt"; my %buildhash; while (my $line = <FILE>) { my $success = 0; my ($build) = $line =~ s/\n//; #if (!-f "$c_streamingBuildData\\${line}\\PlayBuild_IX86.AHV") if (!-f "$c_streamingBuildData/${line}/PlayBuild_IX86.AHV") { print ("${line}: PlayBuild_IX86.AHV does not exist\n"); print PLAYBUILDLOGFILE ("${line}: PlayBuild_IX86.AHV does +not exist\n"); $success = 0; } else { $success = 1; } if ($success eq 1) { # Only add unique directories to the list if (!exists $buildhash{lc("${line}")}) { $buildhash{lc(${line})} = 1; print NEWPLAYBUILDFILE ("${line}\n"); print PLAYBUILDLOGFILE ("${line}: Pass\n"); } else { print PLAYBUILDLOGFILE ("${line}: Duplicate\n"); } } } close PLAYBUILDLOGFILE; close NEWPLAYBUILDFILE; } sub ParsePlayBuildXMACTxt { open NEWPLAYBUILDFILE, ">", "$c_streamingPlayBuildData/PlayBuildXM +AC.txt.good"; open PLAYBUILDLOGFILE, ">", "$c_streamingPlayBuildData/PlayBuildXM +AC.txt.check"; my %buildhash; open FILE, "<", "$c_streamingPlayBuildData/PlayBuildXMAC.txt" or d +ie "Failed to open PlayBuildXMAC.txt"; while (my $line = <FILE>) { my ($build) = $line =~ s/\n//; #if (!-f "$c_streamingBuildData\\${line}\\PlayBuild_XMAC.AHV") if (!-f "$c_streamingBuildData/${line}/PlayBuild_XMAC.AHV") { print ("${line}: PlayBuild_XMAC.AHV does not exist\n"); print PLAYBUILDLOGFILE ("${line}: PlayBuild_XMAC.AHV does +not exist\n"); } else { # Only add unique directories to the list if (!exists $buildhash{lc("${line}")}) { $buildhash{lc(${line})} = 1; print NEWPLAYBUILDFILE ("${line}\n"); print PLAYBUILDLOGFILE ("${line}: Pass\n"); } else { print PLAYBUILDLOGFILE ("${line}: Duplicate\n"); } } } close FILE; close PLAYBUILDLOGFILE; close NEWPLAYBUILDFILE; } sub renameTxtFiles { unlink "$c_streamingPlayBuildData/PlayBuild.txt"; rename "$c_streamingPlayBuildData/PlayBuild.txt.good", "$c_streami +ngPlayBuildData/PlayBuild.txt"; unlink "$c_streamingPlayBuildData/PlayBuildXMAC.txt"; rename "$c_streamingPlayBuildData/PlayBuildXMAC.txt.good", "$c_str +eamingPlayBuildData/PlayBuildXMAC.txt"; } #--------------------------------------------------------------------- +---------- # Main entry function #--------------------------------------------------------------------- +---------- sub Main { ParsePlayBuildTxt(); ParsePlayBuildXMACTxt(); renameTxtFiles(); } Main();

In reply to Porting Code from windows to *nix help by mrbbq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.