We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

search file and send output

hbostic
hbostic asked
on
Medium Priority
207 Views
Last Modified: 2010-03-05
I am a very new Perl user.  I am trying to write some code to read a list of files with lines formatted like the following:  dumptrend /emsdat/trend/ANALOG:AGCGHOST.SYSLOAD-RT_10_3 /emsdat/trend/cps1/lod.ems
I would like the program to get today's date formatted like yymmdd and append this date to the 10_3 and to the ems such that the command looks like the following:

dumptrend /emsdat/trend/ANALOG:AGCGHOST.SYSLOAD-RT_10_3.yymmdd > /emsdat/trend/cps1/lod.emsyymmdd

I then want to run all the commands in the file containing the above lines.  The output from the above command will look like the following:

07/05/98xxxxx00:00:10xxxxx-6.00x01  
07/05/98xxxxx00:00:20xxxxx-6.00x01
07/05/98xxxxx00:00:30xxxx-10.00x01
07/05/98xxxxx00:00:40xxxx-10.00x01
07/05/98xxxxx00:00:50xxxx-20.00x01
07/05/98xxxxx00:01:00xxxxx-5.00x01
07/05/98xxxxx00:01:00xxxxx-5.00x01

where the x's denote spaces.  I would like to search through each of the .ems files each minute for the entries associated with that minute and send the output to a file in the same format.  I would greatly appreciate any assistance I could receive.  I'm under the gun to accomplish this and am trying to learn Perl.  I am running Unix 3.2D on a DEC Unix.
Comment
Watch Question

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
The program will have to run every minute and the output file is continually growing.  The program will need to search through the output of the dumptrend for the associated minutes entries.  

Commented:
It sounds more like you want two programs, or I misunderstood the original question.

Nevertheless, you should have enough to go on with the above code.

Author

Commented:
I only want one program.  The input file which is changed to a .ems file by the dumptrend command is updated every 10 seconds.  I will go through that output which is the .ems file , search for the associated minutes entries and then output that to another file.  That can be accomplished with a while loop and some sort of string search function I believe.  Perhaps, I wasn't clear about all of this.  In addition, it doesn't seem that the sub ParseAndRun is generic.  Will ParseAndRun go through each line of my input file and append the date? There are 15 lines in the input file. Anyway, thank you for your help.  
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.