Operating System - Linux
1822158 Members
3659 Online
109640 Solutions
New Discussion юеВ

Re: Need help with a perl script...

 
MAD_2
Super Advisor

Need help with a perl script...

I'm not savvy with perl and need help modifying one that parses an application tuxedo "ubb" file to find locations where core files may be dumped...

New applications structure does not make use of tuxedo, therefore no need to read any ubb files (the dump location is pretty much static) but the same script should be able to search for core files in either type of application (tuxedo and non-tuxed0... Can only show script to someone who can help!
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
9 REPLIES 9
MAD_2
Super Advisor

Re: Need help with a perl script...

OK, here is more, I figured not much can be done without information:

1) Main chunk of code attached.
2) 4 new applications are coming into play, let's call them: xxa, xxb, xxc, xxd
3) Neither one of these are specified in a ubb file, so in this case no need to havea "$ubbfileloc", however they all have a common "core" dump location, per say:

/main/obe///com/core

PHASE is one of the corresponding "phases", this one is new and unique, named PPR (capitalized) and it's a test one too, and it's the only one that will have structure above for where core files are dumped.
for the new one, is either xxa, xxb, xxc, or xxd.

4) The rest will still follow the same parameters as the attached file (how many files to keep, if to be removed what's the oldest they can be, etc.

Is this understandable?
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Alexander Chuzhoy
Honored Contributor

Re: Need help with a perl script...

1. can you generally describe what your code should do and it doesn't-it'll be much easier to help you this way.

2. There's this site I always use when I need a quick answer:
http://www.perlmonks.org/
you need to register there.
MAD_2
Super Advisor

Re: Need help with a perl script...

Hmmm. I thought I did describe what the code does and does not do, per my description above. Anyhow, it's not "my code", but I am being asked to modify it to fit other needs.

What it does:
1) Looks into a file (a tuxedo ubb file), to find out where it's configured in there for certain applications to do core dumps, if these should fail.
2) Once it finds possible locations of these core dumps, then it goes to those directories (all can have different directories, based on an environment phase fof the application, by that I mean production, development, one of many test, and the specific application), for example, one node may have as many paths as these:
1st is same application in two different test phases; second is 2 more in yet other different phases (core dump locations):
/main/obe/MIG/app1/com/bint
/main/obe/TST/app1/com/bint
/main/obe/TST2/app2/bint
/main/obe/PRP/app2/bint

The script parses the file to get these possible locations. Then it lists the core files in there and removes some if found, based on criteria: a) age, b) number of core dump files found (more than "x" only keep the latest created).

What it does not do:

A new series of applications has been created that does not have a file to parse (named ubb above). For these new applications the general location is:
/main/obe///com/core (it's a common general path).

How can I integrate this entirely different option but yet follow the same guidelines for core files removal as explained above. Since applications of both types may run in the same system we'd like to stick using the one script.

Is this better?

MAD
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with a perl script...

Main attachment was removed but it could be re-posted with a few modifications I need to make if someone could help, otherwise I think I can close... Any ideas?

MAD
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Alexander Chuzhoy
Honored Contributor

Re: Need help with a perl script...

if the general path always ends with core,
then you can append a function to your script that searches some folder recursively and finds the "core" directories.
In the following example it prints the files it finds there,but you can do any manipulation you wish.
Hope I understood and it helps.


#!/usr/bin/perl
use File::Find;
$start_point="/main/obe";
find (\&search,$start_point);
for (@list)
{
@files=glob "$_/*";
for (@files)
{
print "$_\n";
}
}
sub search
{
if (-d $_ && /core$/)
{
push @list,$File::Find::dir."/$_";
}
}
MAD_2
Super Advisor

Re: Need help with a perl script...

Basically, the code has the attached subroutine.

It's called from the following lines:

*****************************************
if ($APPLI_CNT > 0)
{
print "................>";
for ($j = 0; $j < scalar(@LES_APPLI); $j++)
{
chomp($LES_APPLI[$j]);
print "\n>>>>>>>App nber ", $j + 1, " is ", uc($LES_APPLI[$j]),"\n";
for ($t = 0; $t < scalar(@phases) ; $t++)
{
if ($LES_APPLI[$j] =~ /aaa|bbb|ccc|ddd/ )
{
$newpath = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/core";
print "check: $newpath\n";
new_path "$newpath";
}
elsif ($LES_APPLI[$j] =~ /eee|fff|ggg/ ) # special treatment needed for the CPX application
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/etc/cfg/environment_$LES_APPLI[$j]";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
elsif ($LES_APPLI[$j] =~ /ngi/ ) # special treatment needed for the NGI
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/com/etc/cfg/environment_com";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
else
{
$environmentfile = "/main/obe/$phases[$t]/$LES_APPLI[$j]/etc/cfg/environment_$LES_APPLI[$j]";
print "check: $environmentfile\n";
look_for_environment "$environmentfile";
}
}
}
}

Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with a perl script...

Problem... It's looking at the file created with the files it found twice and attempting to remove them a second time, although if the parameters set are met, it has already removed them, complaining with errors like the following:

++++++++++++++++++++++++++++++++++++++

/ama/obe/TST1/bbb/bint/core.20050928 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/ama/obe/TST1/bbb/bint/core.20050930 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/ama/obe/TST1/bbb/bint/core.20050929 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/ama/obe/TST1/bbb/bint/core.20050926 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
/ama/obe/TST1/bbb/bint/core.20050922 not found
/usr/local/bin/sudo: Illegal option -f
usage: sudo -V | -h | -L | -l | -v | -k | -K | [-H] [-P] [-S] [-b] [-p prompt]
[-u username/#uid] -s |
++++++++++++++++++++++++++++++++++++++

This, after the files were actually found, they were there, they were also removed as per the subroutine's guidelines... anyone see the mistake I've made on the modifications I have used?

Thanks for any ideas...

MAD



Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with a perl script...

So, any Perl expert's advise?

MAD
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with a perl script...

No solution found, but apparently I am in the wrong area and really no other responses providing a solution to my problem have been posted...

Thanks!
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with