ronniec has asked for the wisdom of the Perl Monks concerning the following question:

Hi there inmates, I've asked this question before - though from the responses I received I hadn't made myself clear -and I'm still stuck so I'll try and make the question clearer. Some time ago I wrote an FTP module - this is basically a wrapper around Net::FTP to validate filenames, locations etc. This module was used purely to transfer files between UNIX servers. It worked fine and still does. We've recently migrated a server from UNIX to windows and my module was required to be initiated on a windows server instead of UNIX server. I installed active state Perl 5.8 onto this server and then tried to use my FTP module. (I used ppm to ensure that any other CPAN modules called by mine were installed before attempting a run, changed the shebang and the solidi on any file names as they are different between platforms). My script as expected found 3 files to transfer and duly transferred the first file. I checked the target box and the file had been put there but at this point my script just terminates! There are no error messages, there is no returnval sent back to my script for me to peruse it just seems to disappear up it's own uknowwhat! I'm sure that the returnval is not working -I put a print in my script to check the returnval value after each file has been transferred and we never see this display. I'm guessing that this is not a Perl problem but an issue at the server level - some permission or security setting etc. Has anyone encountered this before?
The following is what happens at the command line when I run the script that calls my FTP module:-
C:\home\interface\scripts>cr_trans_sh.pl PARAM 20080805 Useless use of private variable in void context at C:\home\interface\s +cripts\cr_ trans_sh.pl line 317. 2008 is a leap year!!! Sub::date_validation:: Ends Okay The directory in use is E:/Consilium/tasktalk/interfaces/GT-E- +ABEC01-CED AR-005-CREDINV/out sectran: using method PUT_MD5 sectran: transfer attempts will timeout at Thu Aug 14 10:17:35 2008 sectran: sectran: transfer commencing at Thu Aug 14 10:17:15 2008 ... sectran: using put method MD5 sectran: ftp connection established with gala sectran: ifmscron login accepted sectran: set to ascii mode sectran: directory changed to /ifs/spp/spool/IFSLIVE/dataload/cred/in sectran: put E:/Consilium/tasktalk/interfaces/GT-E-ABEC01-CEDAR-005-CR +EDINV/out/ cr_analysis.2008080501 as /ifs/spp/spool/IFSLIVE/dataload/cred/in/xxrc +_total.cr_ analysis.2008080501_d075470e49f78dcff9963982a370e70c successful sectran: ftp session ended with success Aboot tae send the return value! C:\home\interface\scripts>

The FTP module does various different "put" types and I've tried a put_simple and a put_MD5 and both produce the same problem. The method inside mymodule is as follows
# Put file(s) - MD5 ################### if ( ($returnval >= 0) && ($method eq "MD5") ) { my ($lsfile); my (@All); my ($match_file)=$loc_file; opendir (DIR, $loc_dir) or endit("could not find local directory +"); # Convert standard wildcards to regexps $match_file =~ s/\*/\.\*/; $match_file =~ s/\?/\./; my ($fname); while (defined ($lsfile = readdir DIR)) { push (@All, $lsfile) if $lsfile =~ /^$match_file$/; } closedir DIR; if ( ($rem_file) && ($#All gt 0 ) ) { printit("specified to rename remote file but more than one ma +tching local file"); $returnval=-1; } else { foreach $fname (@All) { my ($locname); my ($remname); $locname = $fname; if ($rem_file) { $remname = $rem_file; } else { $remname = $fname; } if ($loc_dir) { $locname = $loc_dir . '/' . $locname; } $locname=~s/\/\//\//g; if ($rem_dir) { $remname = $rem_dir . '/' . $remname; } $remname=~s/\/\//\//g; my ($md5sum)=generate_md5($locname); if ($md5sum eq -1) { printit("md5 checksum generation failed"); $returnval=-1; } else { $remname = $remname . "_" . $md5sum; if ($ftp->put($locname,$remname)) { printit("put $locname as $remname successful"); } else { printit("failed to put $locname as $remname"); $returnval=-1; } } } } } # Close session ############### $ftp->quit; if ($returnval >= 0) { printit("ftp session ended with success"); } else { printit("ftp session ended with failure"); } print "\n\t Aboot tae send the return value!\n" ; return $returnval; print "\n\t I dinna expect tae see this message!!\n" ; }

The following code is part of a loop that calls my (sectran) FTP module:-
foreach $file (@ftp_files) { $rem_file = 'xxrc_total.' . $file ; $renamed_file = $transferred_dir . '/' . $file ; $msg = "Transferring file $file as $rem_file" ; &update_report("$logfile","$msg",1,1,0) or &end_it($mail_msg,$to +,$from,$subject,$msg,$text,$attachments) ; $msg = "<***** Sectran was unable to transfer $file *****>." ; $result = sectran::sectran('CRTRANSSHPARAMS',"$rem_file","$file" +); print "\n\t\tWe never get to this point do we?!\n" ; if ($result != 0) { &ACC_BOX($msg,$logfile) or &end_it($mail_msg,$to,$from,$subje +ct,$msg,$text,$attachments) ; &end_it($mail_msg,$to,$from,$subject,$msg,$null,$logfile) ; } $msg = "File $file has been transferred successfully" ; &update_report("$logfile","$msg",1,1,0) or &end_it($mail_msg,$to +,$from,$subject,$msg,$text,$attachments) ;
As you can see from the command line screen print I'm connecting to the target box and passing all authentication okay and a file is indeed transferred but then for no apparent reason it stops there! Can anyone help?
I should have mentioned that I'm transferring from Windows 2003 to Solaris 10. I believe that solaris 10 is very strict security wise and am wondering if there is some setting there that needs tweaked.

PS The warning at line 317 in the calling script was because I had initialised a value in a for loop twice - fixed that one but still no FTP joy.

Replies are listed 'Best First'.
Re: Are there any issues with Net::FTP between platforms?
by derby (Abbot) on Aug 14, 2008 at 10:37 UTC

    Nothing is jumping out at me as glaringly wrong with the code you've provided ... but it's not all the code. I'd hate to suggest something like there's a DESTROY block on some variable that's causing the script to exit (or abort). Have you tried single stepping through with the debugger?

    -derby

    Update: BTW, what's going on with line 317?