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";
}
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.
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 :