Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Script would not work in UNIX

Script would not work in UNIX

Script would not work in UNIX

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-
   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?)

    $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;
        open CONFIGFILE,$configFileName;    
            if (/^(\w+)=(.*)$/)
                $vars{$1} = $2;
        close CONFIGFILE;

-in ftpGet($), I have the following

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

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

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

Anyone has any idea why it would not run??

RE: Script would not work in UNIX

I actually put the following print statements before the login call, and the all varialbes (userID,password,host) are initialised!

print ("host is " . $host ."\n");
print ("userID is " . $userID . "\n");
print ("password is " . $passwd . "\n");

Note, however, subProcessor.pl uses-

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 = "2.56"; # $Id:$


RE: Script would not work in UNIX

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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close