Okay, haven't done much with perl in a couple years... so forgive me if I don't have much knowledge to work with...
I'm trying to put together a program that will sit with a STDIN prompt asking for a number, and when you enter the number, it will do a directory listing of /usr/local/diskFarm/*/*/ and find the file that has that number in it, and then return the entire path to file.
Some things to know, our filesystem is
/usr/local/farm/company/subcompany/
/usr/local/farm/company/subcompany/log/
/usr/local/farm/company/subcompany/input/
/usr/local/farm/company/subcompany/input/save/
/usr/local/farm/company/subcompany/input/failed/
The number is assigned to each division of the subcompany and is part of the filename for the input file and the log file. The end goal is to enter the subcompany number and have it give me the location of any files with that number, and then tail the last 10 lines of the log... I've got it to the point where it will find the file if it's in input... but it won't tell me where it found it.
#!/usr/bin/perl
#
# This is a program that is intended to allow FEP operators
# a tool that will facilitate in monitoring incoming transmissions
# and preprocessor logs.
#
#------------------- Define Subroutines ------------------#
# lsForCorp Subroutine designed to take an argument and do a directory
# listing looking for that argument on the farm and then returning the
+
# results.
sub lsForCorp {
local($corp) = $_[0];
@farmLs = `ls -ltr /usr/local/farm/*/*/input/`;
foreach $farmLsFile (@farmLs) {
if ($farmLsFile =~ /$corp/) {
print $farmLsFile;
} # end of if statement
} # end of foreach statement
} #end of lsForCorp subroutine
#------------------- End Subroutines ---------------------#
print "What corp are you looking for? " ;
$whatWeWant = <STDIN>;
&lsForCorp("$whatWeWant");
So any ideas on what I need to do differently? I know right now I'm just looking at the input directory, trying to start small, was going to have it check save and failed, and find the log after I figured out the path structure.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.