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

I am using the Net::Ftp::Recursive module to upload an entire directory structure from a windows machine to a unix system via FTP.

The problem I am encountering is that the rput method requires the local directory listing to be pulled by using ls -al

If this is not the case is says to you use:
$ftp->rput( ParseSub => \&get_list )
In order to overwrite the default listing function. I can't get this to work...I am not sure how to write the ParseSub method get_list to return the information about the cwd in the format it wants. The error i get is:
'ls' is not recognized as an internal or external command, operable program or batch file. failed
Any help would be greatly appreciated..

~I'm just a squirrel trying to get a lil nutty~

Replies are listed 'Best First'.
Re: Net::Ftp::Recursive ParseSub Help
by Roger (Parson) on Nov 26, 2003 at 22:22 UTC
    Well, it's because you are on Windows, and 'ls -al' is not a valid Windows command. You will have to use the Windows/DOS equivalent of directory listing command. You could give the following a try, by overriding the default 'ls -al' command under unix with 'cmd.exe /C dir /B' command under Windows.

    $ftprput ( ParseSub => \&get_list, DirCommand => 'cmd.exe /C dir /b' ); # or this - $ftprput ( ParseSub => \&get_list, DirCommand => 'dir /b' ); # use current cmd shell
      Thanks I got the ls -al error to go away but the new error i am getting is:
      Can't call method "isPlainFile" on an undefined value at C:/Perl/site/ +lib/Net/FT P/Recursive.pm line 248.
      I need to write a function get_list that sets these values somehow but i am not sure how to start. This had to have been done before since it is neccessary if you use this on a windows platform.

      THanks in advance for your help.
Re: Net::Ftp::Recursive ParseSub Help
by tcf22 (Priest) on Nov 28, 2003 at 16:40 UTC
    This should work for your ParseSub if you are using "cmd /b" as your listing command.
    sub get_list { my @file_list; foreach my $ele (@_){ my ($name); if(-d (getcwd."/$ele")){ $name = 'IsDirectory'; }else{ $name = 'IsPlainFile'; } my $filename = getcwd."/$ele"; my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); my @fields = ($mode,$nlink,$uid,$gid,$size,$mtime,$ele); push(@file_list,Net::FTP::Recursive::File->new(OriginalLine => + $ele, Fields => \@fields, $name => 1)); } return @file_list; }

    - Tom