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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script would not work in UNIX

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I developed some script with Perl on NT using Active Perl 5.6, and now copying the scripts over to a Solaris box, also running Active Perl 5.6 and it wouldn't work!
The situation is as follows-
Code:
perl mainProcessor.pl myConfig.cfg

-mainProcessor.pl 'require' subProcessor.pl
-mainProcessor.pl calls parse() in subProcessor.pl
-parse in subProcessor.pl calls ftpGet() in subProcessor.pl
-I have the following code within mainProcessor.pl (no subroutines), and also in subProcessor.pl (in the 'main' area. outside the subroutines) (do I need to do this anyway?)
Code:
    $configFileName = $ARGV[0];
    #Only read a file that exists and is a text file
    if (! (-e $configFileName) or !(-T $configFileName))
    {
        die "could not find config file ". $configFileName;
    }
    else
    {
        open CONFIGFILE,$configFileName;    
        while(<CONFIGFILE>)
        {
            if (/^(\w+)=(.*)$/)
        	{
                $vars{$1} = $2;
            }
        }
        close CONFIGFILE;
    }

-in ftpGet($), I have the following
Code:
    my $host   = $vars{&quot;host&quot;};
    my $userID = $vars{&quot;userID&quot;};
    my $passwd = $vars{&quot;passwd&quot;};
    my $noOfRetry    = $vars{&quot;retry&quot;};
    my $retryCounter = $vars{&quot;retry&quot;};
    my $notDone=1;
    while ($retryCounter>0 and $notDone==1)
    {
        #The 1st,2nd, etc. time FTP is happening
        my $times= 1 - ($retryCounter - $noOfRetry);  
        logInfo(&quot;Open connection to &quot; .$host);
        $ftp = Net::FTP->new($host, debug=>1,Passive=>1) 
                 or die &quot;couldn't connect to host&quot;

        $ftp->login($userID,$passwd) or die &quot;couldn't log in&quot;
#etc etc etc

-Runnning everything on NT is perfect, running it on Solaris results in the following error-
Can't call method &quot;login&quot; on an undefined value at subProcessor.pl line 440.


Anyone has any idea why it would not run??
 
I actually put the following print statements before the login call, and the all varialbes (userID,password,host) are initialised!
Code:
print (&quot;host is &quot; . $host .&quot;\n&quot;);
print (&quot;userID is &quot; . $userID . &quot;\n&quot;);
print (&quot;password is &quot; . $passwd . &quot;\n&quot;);

Note, however, subProcessor.pl uses-
Code:
use Net::FTP;           #For FTPing files
use Net::Cmd;           #For FTP error logging

Both under the NT and Solaris installation, I have the FTP.pm under SiteLib\Net directory and the version is as follows-
$VERSION = &quot;2.56&quot;; # $Id:$

Wassup?
 
I now find out that it seems to be the $ftp variable that is not initialised and the die on $ftp= Net::FTP->new(etc etc)....

Strangetly, doing a manually FTP to the remote server does work, any reason why I can't FTP in Solaris?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top