Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl job failing on UNLESS command 2

Status
Not open for further replies.

djbjr

Programmer
Dec 7, 2001
106
0
0
US
Probably a poor subject line but I really dont know what I am doing. I am an Oracle developer that has inherited a 9 year old Perl script that moves files and kicks off Sql*Loader scripts.

We are moving off of Unix and on to Linux and this script is acting crazy now. I wonder if any of you guys can help me out.

My script is failing on the following piece of the script

Code:
#-------------------------------------------------------------------------------
# Make sure input load file exists and has trailer
#-------------------------------------------------------------------------------


# unless (-e "$hrdat/inproc/$filename")
unless ( `[ -f "$hrdat/inproc/$filename" ] && echo 0`)
{
     &fatal_error("ERROR - Cannot find file $hrdat/inproc/$filename");
}
     $file_fnd = 1;

I am assuming it is checking to see that the file exists which it does and I am pretty sure that it is looking in the right place because when I get the error message I see the following

Code:
hr_load 08/23/106 13:13:37  ps_dep_ben_eff.data Processing FILE-ID: ps_dep_ben_eff.data, FILENAME:
hr_load 08/23/106 13:13:37  ps_dep_ben_eff.data ERROR - Cannot find file /usr/local/hr/slot/dat/inproc/
hr_load 08/23/106 13:13:37  ps_dep_ben_eff.data UNSUCCESSFUL END

The file is located in /usr/local/hr/slot/date/inproc/ps_dep_ben_eff.data and the file is read/write for all users. Any suggestions of what might be going on here?

I know this may seem a little vague but I am not a Perl programmer and I am trying to get by while I am waiting for an approval for a contractor to come in.

Thanks in advance
dj
 
ERROR - Cannot find file /usr/local/hr/slot/dat/inproc/

This tells us that $filename is not a currently populated variable

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
It looks like $filename isn't defined with a value. Compare this code with the actual output:

Code:
     &fatal_error("ERROR - Cannot find file $hrdat/inproc/$filename");

Code:
ERROR - Cannot find file /usr/local/hr/slot/dat/inproc/

It looks like $filename doesn't have a value because it didn't show up in the error message. Double-check the code up a little higher to see if you can't find the problem.
 
try like this:

Code:
unless (-e "$hrdat/inproc/$filename")
{
    &fatal_error("ERROR - Cannot find file $hrdat/inproc/$filename");
}

assumes "$hrdat/inproc/$filename" is the full path.

-f checks if it's a file
-e checks if it exists

you can probably use either one inthis case, but there are differences.
 
I hear what your two are saying but my thoughts that the file name was wraping to the next line.

If you look at my error log, it continues with the filename....or maybe you are right and this is an additional message.

Thanks for your help

In the meantime I will try the -e approach.
 
one of us is invisible ;-) [3 within 3 minutes, new record]

show us your fatal_error sub, this could be a scoping problem

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks for your replys, the problem was that I had an incomplete parameter file so the full path of the file was not being searched for.

Now I have a new problem. I am getting an error that it cant open the log file.

Code:
hr_load 08/24/106 08:58:47  ps_disability STARTED
hr_load 08/24/106 08:58:47  ps_disability Processing FILE-ID: ps_disability, FILENAME: ps_disability.data
hr_load 08/24/106 08:58:47  ps_disability ERROR - CANNOT OPEN FILE /usr/local/hr/slot/dat/inproc/ps_disability.data.log
hr_load 08/24/106 08:58:47  ps_disability UNSUCCESSFUL END

The code that I am using to access the log file is here.

Code:
{
   $loadlog = "$hrdat/inproc/$filename.log";
   open (LOADLOG,  "$loadlog") || &fatal_error("ERROR - CANNOT OPEN FILE $loadlog");

    while (<LOADLOG>)
    {
        if (/successfully loaded./)
        {
            ($a, $load_cnt, $c, $d, $e) = (split (/ +/, $_));
        }
    }

    close (LOADLOG);

    unless (defined($load_cnt))
    {
        &fatal_error("ERROR - Cant get sqlload load totals from logfile $loadlog");
    }


}

It looks like it is trying to open a file that doesnt exist....is that correct?

The part that bothers me about this issue is that this script worked fine on our Unix environment but is bombing out now on our Linux environment.

One thing that I have double checked is that the user has full privledges to the folder where the log file needs to be created.
 
/usr/local/hr/slot/dat/inproc/ps_disability.data.log

or

/usr/local/hr/slot/dat/inproc/ps_disability.data

if it's just .data change this line
Code:
   $loadlog = "$hrdat/inproc/$filename[COLOR=red].log[/color]";
to this
Code:
   $loadlog = "$hrdat/inproc/$filename";

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Paul-

Thanks for the hint but that isnt going to work. The .data file is the flat file that I am going to use to load into Oracle.

I changed it to look like .log instead of .data.log and it is still giving me the same error.
 
Paul-

Thanks for the help, I have figured it out. The problem was that the file was not being created because the sql*loader command that I was running earlier in the script was not executing.

Thanks a ton and I will post again if I need more help

dj
 
yw ;-), thanks for posting back

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top