Sponsored Content
Top Forums Shell Programming and Scripting [Perl] Module for recursive listing of remote Windows shares Post 302976920 by Fundix on Friday 8th of July 2016 04:44:04 AM
Old 07-08-2016
Question [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
 

10 More Discussions You Might Find Interesting

1. IP Networking

Mounting shares from a Windows PC

Hi... I can ping my Windows PC using both the IP address and NetBios name and I can ping my Linux box the same, IP address and NetBios name. I can even use smbclient to see the shares on my Windows PC. But I can't map the shares so that Linux sees it as a drive. How do I do that? (5 Replies)
Discussion started by: SeCBerm
5 Replies

2. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

3. AIX

listing files on remote server

I am writing a script where in i have to log into a remote machine and check for necessary file by typing (ls -ltr *200505) (this gets all 05month of 2008 yr files) and if files are found get them to the local machine. If not found print a message saying no files on local machine. When i was... (3 Replies)
Discussion started by: vasuarjula
3 Replies

4. UNIX for Dummies Questions & Answers

recursive directory listing with ownership

i'm playing around with "ls" and "find" and am trying to get a print out of directories, with full path, (recursive) and their ownership.... without files or package contents (Mac .pkg or .mpkg files). I'd like it simply displayed without much/any extraneous info. everything i've tried, and... (5 Replies)
Discussion started by: alternapop
5 Replies

5. UNIX for Dummies Questions & Answers

Errors when connecting to SMB shares from Windows

Hi all I have a server running Oracle Linux. When i try \\linux-server\share I get prompted for username & password or I get a permission denied error. I see these errors in the messages file on the Linux server: smbd: auth/auth_util.c:create_builtin_administrators(792) Feb 15 10:39:13... (0 Replies)
Discussion started by: wbdevilliers
0 Replies

6. 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

7. Shell Programming and Scripting

Recursive Replication of Unix folders to Windows

Requirements: ftp files recursively from unix to windows. Replicate directory paths on unix (source) to windows (destination) and place files in their respective folders. There are no set number of files per directory nor fix number of dirA or dirB etc.... Source OS: Solaris... (5 Replies)
Discussion started by: mlv_99
5 Replies

8. Shell Programming and Scripting

Unable to Install "Devel-Profile" perl module in windows.

Hi, I want to install 'Devel-Profile' in windows but i am not able to install. Here is the error. PPM> install Devel-Profile Install package 'Devel-Profile?' (y/N): y Installing package 'Devel-Profile'... Error installing package 'Devel-Profile': Could not locate a PPD file for... (3 Replies)
Discussion started by: vanitham
3 Replies

9. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: Fundix
2 Replies

10. 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
SmbClient(3pm)						User Contributed Perl Documentation					    SmbClient(3pm)

NAME
Filesys::SmbClient - Interface for access Samba filesystem with libsmclient.so SYNOPSIS
use POSIX; use Filesys::SmbClient; my $smb = new Filesys::SmbClient(username => "alian", password => "speed", workgroup => "alian", debug => 10); # Read a file my $fd = $smb->open("smb://jupiter/doc/general.css", '0666'); while (defined(my $l= $smb->read($fd,50))) {print $l; } $smb->close(fd); # ... See section EXAMPLE for others scripts. DESCRIPTION
Provide interface to access routine defined in libsmbclient.so provided with Samba. Since 3.0 release of this package, you need a least samba-3.0.2. For prior release of Samba, use Filesys::SmbClient version 1.x. For old and 2.x release, this library is available on Samba source, but is not build by default. Do "make bin/libsmbclient.so" in sources directory of Samba to build this libraries. Then copy source/include/libsmbclient.h to /usr/local/samba/include and source/bin/libsmbclient.so to /usr/local/samba/lib before install this module. If you want to use filehandle with this module, you need Perl 5.6 or later. When a path is used, his scheme is : smb://server/share/rep/doc VERSION
$Revision: 3.1 $ FONCTIONS
new %hash Init connection Hash can have this keys: o username o password o workgroup o debug o flags : See set_flag Return instance of Filesys::SmbClient on succes, die with error else. Example: my $smb = new Filesys::SmbClient(username => "alian", password => "speed", workgroup => "alian", debug => 10); set_flag Set flag for smb connection. See _SMBCCTX->flags in libsmclient.h Flag can be: SMB_CTX_FLAG_USE_KERBEROS SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON Tie Filesys::SmbClient filehandle This didn't work before 5.005_64. Why, I don't know. When you have tied a filehandle with Filesys::SmbClient, you can call classic methods for filehandle: print, printf, seek, syswrite, getc, open, close, read. See perldoc for usage. Example: local *FD; tie(*FD, 'Filesys::SmbClient'); open(FD,"smb://jupiter/doc/test") or print "Can't open file:", $!, " "; while(<FD>) { print $_; } close(FD); or local *FD; tie(*FD, 'Filesys::SmbClient'); open(FD,">smb://jupiter/doc/test") or print "Can't create file:", $!, " "; print FD "Samba test"," "; printf FD "%s", "And that work ! "; close(FD); Directory mkdir FILENAME, MODE Create directory $fname with permissions set to $mode. Return 1 on success, else 0 is return and errno and $! is set. Example: $smb->mkdir("smb://jupiter/doc/toto",'0666') or print "Error mkdir: ", $!, " "; rmdir FILENAME Erase directory $fname. Return 1 on success, else 0 is return and errno and $! is set. ($fname must be empty, else see rmdir_recurse). Example: $smb->rmdir("smb://jupiter/doc/toto") or print "Error rmdir: ", $!, " "; rmdir_recurse FILENAME Erase directory $fname. Return 1 on success, else 0 is return and errno and $! is set. Il $fname is not empty, all files and dir will be deleted. Example: $smb->rmdir_recurse("smb://jupiter/doc/toto") or print "Error rmdir_recurse: ", $!, " "; opendir FILENAME Open directory $fname. Return file descriptor on succes, else 0 is return and $! is set. readdir FILEHANDLE Read a directory. In a list context, return the full content of the directory $fd, else return next element. Each elem is a name of a directory or files. Return undef at end of directory. Example: my $fd = $smb->opendir("smb://jupiter/doc"); foreach my $n ($smb->readdir($fd)) {print $n," ";} close($fd); readdir_struct FILEHANDLE Read a directory. In a list context, return the full content of the directory FILEHANDLE, else return next element. Each element is a ref to an array with type, name and comment. Type can be : SMBC_WORKGROUP SMBC_SERVER SMBC_FILE_SHARE SMBC_PRINTER_SHARE SMBC_COMMS_SHARE SMBC_IPC_SHARE SMBC_DIR SMBC_FILE SMBC_LINK Return undef at end of directory. Example: my $fd = $smb->opendir("smb://jupiter/doc"); while (my $f = $smb->readdir_struct($fd)) { if ($f->[0] == SMBC_DIR) {print "Directory ",$f->[1]," ";} elsif ($f->[0] == SMBC_FILE) {print "File ",$f->[1]," ";} # ... } close($fd); closedir FILEHANDLE Close directory $fd. Files stat FILENAME Stat a file FILENAME. Return a list with info on success, else an empty list is return and $! is set. List is made with: o device o inode o protection o number of hard links o user ID of owner o group ID of owner o device type (if inode device) o total size, in bytes o blocksize for filesystem I/O o number of blocks allocated o time of last access o time of last modification o time of last change Example: my @tab = $smb->stat("smb://jupiter/doc/tata"); if ($#tab == 0) { print "Erreur in stat:", $!, " "; } else { for (10..12) {$tab[$_] = localtime($tab[$_]);} print join(" ",@tab); } fstat FILEHANDLE Like stat, but on a file handle rename OLDNAME,NEWNAME Changes the name of a file; an existing file NEWNAME will be clobbered. Returns true for success, false otherwise, with $! set. Example: $smb->rename("smb://jupiter/doc/toto","smb://jupiter/doc/tata") or print "Can't rename file:", $!, " "; unlink FILENAME Unlink FILENAME. Return 1 on success, else 0 is return and errno and $! is set. Example: $smb->unlink("smb://jupiter/doc/test") or print "Can't unlink file:", $!, " "; open FILENAME open FILENAME, MODE Open file $fname with perm $mode. Return file descriptor on success, else 0 is return and $! is set. Example: my $fd = $smb->open("smb://jupiter/doc/test", 0666) or print "Can't read file:", $!, " "; my $fd = $smb->open(">smb://jupiter/doc/test", 0666) or print "Can't create file:", $!, " "; my $fd = $smb->open(">>smb://jupiter/doc/test", 0666) or print "Can't append to file:", $!, " "; read FILEHANDLE read FILEHANDLE, LENGTH Read $count bytes of data on file descriptor $fd. It lenght is not set, 4096 bytes will be read. Return buffer read on success, undef at end of file, -1 is return on error and $! is set. FILEHANDLE must be open with open of this module. write FILEHANDLE, $buf write FILEHANDLE, @buf Write $buf or @buf on file descriptor $fd. Return number of bytes wrote, else -1 is return and errno and $! is set. Example: my $fd = $smb->open(">smb://jupiter/doc/test", 0666) or print "Can't create file:", $!, " "; $smb->write($fd, "A test of write call") or print $!," "; $smb->close($fd); FILEHANDLE must be open with open of this module. seek FILEHANDLE, POS Sets FILEHANDLE's position, just like the "fseek" call of "stdio". FILEHANDLE may be an expression whose value gives the name of the filehandle. The values for WHENCE is always SEEK_SET beacause others didn't work on libsmbclient.so FILEHANDLE must be open with open of this module. close FILEHANDLE Close file FILEHANDLE. Return 0 on success, else -1 is return and errno and $! is set. Print method unlink_print_job PRINTER_URL, IDJOB Remove job number IDJOB on printer PRINTER_URL print_file DOCUMENT_URL, PRINTER_URL Print file DOCUMENT_URL on PRINTER_URL TODO
o chown o chmod o open_print_job o telldir o lseekdir EXAMPLE
This module come with some scripts: t/*.t Just for check that this module is ok :-) smb2www-2.cgi A CGI interface with these features: o browse workgroup ,share, dir o read file o upload file o create directory o unlink file, directory COPYRIGHT
The Filesys-SmbClient module is Copyright (c) 1999-2003 Alain BARBET, France, alian at cpan.org. All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.14.2 2006-09-13 SmbClient(3pm)
All times are GMT -4. The time now is 02:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy