Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Perl error: Can't call method "value" on an undefined value Post 302674895 by vpundit on Friday 20th of July 2012 05:22:36 PM
Old 07-20-2012
Perl error: Can't call method "value" on an undefined value

Hi,

I am running a perl script to automate a process and I keep running into a error can't find the "value"

Code:
Can't call method "value" on an undefined value at process_file.pl line 44.
file is CVS
cell is ifdfdxrfmp.ksh

Here is the script I have also attached it as well:

Code:
#################################
#    process_file.pl        #         
#################################

#!/user/bin/perl -w

use strict;
use Spreadsheet::ParseExcel;
use Net::SMTP;

#Parse excel file
#Replace Perl_test.xls with the excel filename
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse("Perl_test.xls");

#Get tag from excel cell N9
my $worksheet = $workbook->worksheet('Scripts');
my $tagcell = $worksheet->get_cell(8, 13);
my $tag = $tagcell->value();

#Get checkout dir from excell cell O9
my $dircell = $worksheet->get_cell(8, 14);
my $dir = $dircell->value();

system("date +%m/%d/%Y' '%T >> process_file_log"); 
system("echo the tag is $tag >> process_file_log");
system("echo the checkout dir is $dir >> process_file_log");

#If checkout dir starts with "/", then abort and send email with error
if ($dir =~ /^\//) {
    system("echo 'Error: The checkout dir starts with /' > error_log");
}
else {
    #Run CVS check out command
    system ("echo Checking out files from CVS ... >> process_file_log");
    system("cvs co -r $tag $dir >> process_file_log");
    
    #Compare files with the files listed from cell L9 to L58
    foreach my $file (glob("$dir/*")) {
        $file =~s/.*\///;
        print "file is $file\n";
        foreach my $row (8..57) {
            my $fcell = $worksheet->get_cell($row, 11);
            my $name = $fcell->value();
            print "cell is $name\n";
            
            #If file name is the same
            if ($file eq $name) {
                my $targetcell = $worksheet->get_cell($row, 15);
                my $target = $targetcell->value();
                print "target dir is $target\n";
                system("mkdir -p $target");

                #If file with same name already exists
                foreach my $f (glob("$target/*")) {
                    $f =~ s/.*\///;    
                    if ($f eq $file) {
                        print "$f already exists \n";
                        #Current date and time
                        my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time);
                        $mon  += 1;
                        $year += 1900;
                        my $time = (sprintf "%02d%02d", $hour, $min);
                        my $date = $year.$mon.$mday.$time;
                        my $new = $f.".B".$date;
                        system("echo $f already exists >> process_file_log");                        
                        system("echo Renaming $f to $new >> process_file_log");
                        system("mv $target/$f $target/$new");
                        last;
                    }
                }
                
                #Copy checked out file to target dir
                system("echo Copying $file to $target/ >> process_file_log");
                system("cp $dir/$file $target/");
                                                    
                #If file ends with .ksh, .sh or .pl
                #Then chmod 750
                system("echo Changing the permission of $file >> process_file_log");
                if ($file =~ /\.ksh/) {
                    system("chmod 750 $target/$file");
                }
                elsif ($file =~ /\.sh/) {
                    system("chmod 750 $target/$file");
                }
                elsif ($file =~ /\.PL/) {
                    system("chmod 750 $target/$file");
                }
                #Else chmod 660
                else {
                    system("chmod 660 $target/$file");
                }
                #Assign owner and group        
                system("echo Changing the owner and group of $file >> process_file_log");        
                system("chown ifstech $target/$file");
                system("chgrp support $target/$file");
                
            }
        }
    }
}
system("echo '==============================================================================>' >> process_file_log");

#Send email if there is an error
open( my $error, "<error_log");
my @log = <$error>;
if (scalar(@log) == 0) {
    close $error;
}
else {
    #Define the mail settings here
    my $mailhost = '10.201.40.28'; 
    my $sender = 'sender@domain.com';
    my $recipient = 'receiver@domain.com';
    
    my $smtp = Net::SMTP->new("$mailhost");
    
    #Mail header and body    
    my $subject = 'Error message';
    $smtp->mail("$sender");
    $smtp->to($recipient);
    $smtp->data();
    $smtp->datasend("To: $recipient \n");
    $smtp->datasend("From: $sender \n");
    $smtp->datasend("Subject: $subject \n" );
    $smtp->datasend("\n");
    $smtp->datasend("@log");
    $smtp->datasend("\n");
    $smtp->dataend();
    $smtp->quit;

    close $error;
}


It's supposed to find a files within the checked out dir and then compare it to the excel spreadsheet. it finds the folder "CVS" but not the file.

Last edited by vpundit; 11-23-2012 at 01:38 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

shared object "undefined symbol: fstat" error

Didn't have this problem in AIX, but ported to Linux with GCC compiler and am now getting a runtime error: tssutil: symbol lookup error: /work/agility/devel/bin/libagam.so: undefined symbol: fstat I'm sure most of you know that fstat is an intrinsic function just like printf, memcpy, etc. When I... (5 Replies)
Discussion started by: marcus121
5 Replies

2. AIX

Getting error "Undefined symbol: .u_strlen_2_6"

Hi, I am using xlC compiler. The compilation goes fine but at the time of linking it gives the following error ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. ld: 0711-317 ERROR: Undefined symbol: .u_strlen_2_6 ld: 0711-317 ERROR: Undefined symbol:... (0 Replies)
Discussion started by: nachiketv
0 Replies

3. Programming

error "Invalid argument" returned after call sched_setscheduler

the code is below and the was run on Solaris 9. ----------------------------- struct sched_param param; param.sched_priority = 99; if(sched_setscheduler(0, SCHED_RR, &param) == -1) { perror("setting priority"); exit(1); } ------------------------------- after the... (1 Reply)
Discussion started by: robin.zhu
1 Replies

4. Shell Programming and Scripting

bash: "undefined variable" and pipe

Hi, haven't found anything about this through searching, so may be a new topic: when doing this: set -o nounset set -o errexit find . -name "*.lib" | while read library; do echo ${libary} done echo "after while" I expect the script to exit within the while loop (because of nounset and... (6 Replies)
Discussion started by: nagaidhlig
6 Replies

5. Shell Programming and Scripting

Can't locate object method "fetchrow_array" Error

Hi, I have a perl script which is interacting with Database. I have following line of code : ================================================= sub BEGIN { #use Getopt::Std; #getopt ('S'); #($STEAP)=($opt_S); use lib ("/home/perl_lib"); use... (1 Reply)
Discussion started by: rawat_me01
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Solaris

svc:/network/physical:default: Method "/lib/svc/method/net-physical" failed with exit status 96. [ n

After a memory upgrade all network interfaces are misconfigued. How do i resolve this issue. Below are some out puts.thanks. ifconfig: plumb: SIOCLIFADDIF: eg000g0:2: no such interface # ifconfig eg1000g0:2 plumb ifconfig: plumb: SIOCLIFADDIF: eg1000g0:2: no such interface # ifconfig... (2 Replies)
Discussion started by: andersonedouard
2 Replies

8. Programming

make fails with "undefined reference to..."

i am compiling a program called vasp on suse and get the following error. there are many more preprocess and ifort commands prior so i just grabbed the tail of the log file: ./preprocess <main.F | /usr/bin/cpp -P -C -traditional >main.f90 -DMPI -DHOST=\"LinuxIFC\" -DIFC -Dkind8 -DNGZhalf... (6 Replies)
Discussion started by: crimso
6 Replies

9. Programming

Compiling C++ code with NetCDF libraries: "undefined reference"

Hi! I am trying to compile a C++ code with cmake and gcc on Ubuntu. The code uses NetCDF4 libraries. I specify the path to these libraries as follows: -I/usr/local/include -L/usr/local/lib -lnetcdf -lnetcdf_c++4 "ccmake" and "cmake" work fine. After typing "make" I receive the error... (0 Replies)
Discussion started by: Alauda
0 Replies

10. Shell Programming and Scripting

Perl failure with "main::$fn" used only once:" in error logs

Hi all, Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error: - I have a static html file which calls the cgi-perl script. HTML Code: <html> <head> <title> Hey Dude! </title> </head> <body> <form method="POST"... (3 Replies)
Discussion started by: bashily
3 Replies
All times are GMT -4. The time now is 05:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy