Using Perl to explore recursively remote windows path from AIX

Hi all,

I am using Perl 5.8.8 on an Aix 6.1.0.0 to script a program which will retrieve files recursively on a remote Windows 2003 server and copy some of them on my Aix server.
MobaSSH is installed on that windows server.

When I used scp on the command line, it works fine, but not in a script.
I first try to list the glob files, but no way.
I already used that Perl module for remote Aix or Linux servers and it works fine.

#!/usr/bin/perl -w

use strict;
use Net::SFTP::Foreign;

my $host="comp";
my $user="john";
my $dir="C:/temp/*"

my $sftp = Net::SFTP::Foreign->new("$user\@$host");

my @files = $sftp->glob("$dir", names_only => 1);

foreach my $l (@files) {
  print "$l\n";
}

Thank You for your help
--
Pat (France)

Hello Fundix,

Just want to let you know if we have a Shared storage at Windows level, we can make that storage available too in UNIX in form of NFS etc.
Please do check with your storage team if this is possible, it may help you and can save your time and effort to manually/automatically copying the data from one system to another.

Thanks,
R. Singh

Hello RavinderSingh13,

Windows admins create a d:\temp share on my comp server.
I used the following code :

#!/usr/bin/perl -w

use strict;
use Net::SFTP::Foreign;

my $host="comp";
my $user="john";
my $dir="d:/temp/*"

# Command KO, do not work
print "Test SFTP\n";
my $sftp = Net::SFTP::Foreign->new("$user\@$host");
my @files = $sftp->glob("$dir", names_only => 1);

foreach my $l (@files) {
  print "$l\n";
}

# commande OK, works
print "Test LS\n";
my @files2=`ssh $user\@$host 'ls -R $dir'`;

foreach my $l (@files2) {
  print "$l";
}

The LS test works fine and i got the following output :

Test SFTP
Test LS
d:/temp/3407_2.prt
d:/temp/4656_1.prt
d:/temp/4656_2.prt
d:/temp/4718_1.prt
d:/temp/4718_2.prt
d:/temp/SuHOST.bat
d:/temp/agtepo45.log
d:/temp/debug.txt
d:/temp/droits.bat
d:/temp/icone.bat
d:/temp/iconebis.bat
d:/temp/iconeged.bat
d:/temp/lo_config_printer.txt
d:/temp/lo_default_printer.txt
d:/temp/ora.bat
d:/temp/sqlnet.ora
d:/temp/supappli.bat
d:/temp/tnsnames.ora

d:/temp/dir1:
3407_2.bat
4656_1.prt
4656_2.prt
4718_1.prt
4718_2.prt
dir2

d:/temp/dir1/dir2:
jboss.log

I found there that I must use Net::SSH2, but that module can't be installed on my Aix.

If the LS solution works i will create extra code to filter my list but i regret i can't use Net::SFTP::Foreign module on Windows.

Maybe there another solution/module which will works fine to retrieve remote Windows/UNIX file lists.

Thank You