Using Perl to explore recursively remote windows path from AIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using Perl to explore recursively remote windows path from AIX
# 1  
Old 02-12-2015
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.

Code:
#!/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)
# 2  
Old 02-12-2015
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
# 3  
Old 02-12-2015
Hello RavinderSingh13,

Quote:
Originally Posted by RavinderSingh13
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 :

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 :
Code:
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Samba 3.6 on AIX 7.1 - Windows 10 Access to AIX file shares using Active Directory authentication

I am running AIX 7.1 and currently we have samba 3.6.25 installed on the server. As it stands some AIX folders are shared that can be accessed by certain Windows users. The problem is that since Windows 10 the guest feature no longer works so users have to manually type in their Windows login/pwd... (14 Replies)
Discussion started by: linuxsnake
14 Replies

2. Shell Programming and Scripting

[Perl] Module for recursive listing of remote Windows shares

Hi, I'm looking for a Perl module which can recursively list remote Windows shares from within a Linux machine. I've tried Filesys::SmbClient ans Filesys:SmbClientPars but they just list the current directory Thank You for your help (4 Replies)
Discussion started by: Fundix
4 Replies

3. UNIX for Advanced & Expert Users

DOS/VB script of Remote Windows Server from AIX

Hi We use to run DOS and VB script in Windows Server . Now the requirement is to trigger the same script from AIX server by shell script , thus it would be executed in Remote Windows Server . Is it possible ( though SSH or any other way ) ? Thanks (2 Replies)
Discussion started by: Sourajit Seth
2 Replies

4. AIX

How to set up remote X Windows on AIX ?

Hi, I want to display a program on my local workstation, that is running on a remote AIX, and I have done the following: install an X server (Xming) on my windows machine enable X11 forwarding in Putty enable X11 forwarding for the SSH daemon restart SSH daemon text X... (9 Replies)
Discussion started by: SteAlma
9 Replies

5. UNIX for Dummies Questions & Answers

echo windows path

I have developed a script that transfers files from a UNIX machine to a Windows machine. Transferring the files is working perfectly, but my echo statements are displaying the destination (Windows) path names incorrectly. I understand that it is the "\" that is causing this, but is there anyway... (5 Replies)
Discussion started by: shammah77
5 Replies

6. Shell Programming and Scripting

Library on Remote machine or $PATH is not working..

I don't know how to put this. However here is the problem. While executing command remotely on a Unix machine i get an error /usr/lib/hpux32/dld.so: Unable to find library 'libxerces-c.sl.21'. However when i execute the command on the remote machine locally. it works fine. Also i have... (2 Replies)
Discussion started by: suraj.sheikh
2 Replies

7. Shell Programming and Scripting

shellscript on AIX to download file from windows to AIX

i require the shell script that is running on the AIX to download a file from Windows desktop to the location where the shell script resides onthe AIX system. I have used the below code: but it throwing the error as below.please help me at the earliest to resolve the issue. error message :... (1 Reply)
Discussion started by: kvkc
1 Replies

8. Shell Programming and Scripting

Execution difference in perl scripts for windows / AIX

Hi, I have perl script abc.pl which runs perfectly fine on windows ( execution from cmd). Now i tried to execute the same perl module on the AIX server after defining the captureoutput.pm and other relevant changes. But its behaving very weirdly as a portion of the URL which is formed by... (3 Replies)
Discussion started by: slayer0611
3 Replies

9. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

10. Shell Programming and Scripting

FTP command to search recursively in windows folder

Hi what command to be used to FTP files from the windows directory into a folder in unix environment using shell script The script should be able to recursively search into 100 subdirectories within my windows directory for .xml files. Can anyone help me with this... thnx (6 Replies)
Discussion started by: lakshmis10
6 Replies
Login or Register to Ask a Question